Tarea #333 Ultimas Entradas
This commit is contained in:
parent
b8ff2dbb0a
commit
37e52b54b0
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue