Tarea #333 Ultimas Entradas

This commit is contained in:
gerard 2018-06-20 12:30:59 +02:00
parent b8ff2dbb0a
commit 37e52b54b0
2 changed files with 23 additions and 3 deletions

View File

@ -18,12 +18,21 @@ class Controller {
return this._item;
}
set entriesDate(value) {
this._entriesDate = value;
this._getLastEntries();
}
get entriesDate() {
return this._entriesDate;
}
_defaultEntriesDate() {
let defaultDate;
defaultDate = new Date();
defaultDate.setDate(defaultDate.getDate() - 75);
defaultDate.setHours(0, 0, 0, 0);
this.entriesDate = defaultDate;
this._entriesDate = defaultDate;
}
_getLastEntries() {

View File

@ -1,11 +1,12 @@
import './index.js';
fdescribe('Item', () => {
describe('Item', () => {
describe('Component vnItemLastEntries', () => {
let $componentController;
let $scope;
let controller;
let $httpBackend;
let defaultDate;
beforeEach(() => {
angular.mock.module('item');
@ -31,9 +32,19 @@ fdescribe('Item', () => {
});
});
describe('set entriesDate()', () => {
it(`should set entriesDate and call _getLastEntries()`, () => {
spyOn(controller, '_getLastEntries');
controller.item = [];
controller.entriesDate = new Date();
expect(controller._getLastEntries).toHaveBeenCalledWith();
expect(controller.item).toEqual([]);
});
});
describe('_defaultEntriesDate()', () => {
it(`should set entriesDate to a date 75 days ago`, () => {
let defaultDate;
defaultDate = new Date();
defaultDate.setDate(defaultDate.getDate() - 75);
defaultDate.setHours(0, 0, 0, 0);