40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
|
import './index';
|
||
|
|
||
|
describe('client unpaid', () => {
|
||
|
describe('Component vnClientUnpaid', () => {
|
||
|
let controller;
|
||
|
|
||
|
beforeEach(ngModule('client'));
|
||
|
|
||
|
beforeEach(inject(($componentController, $rootScope) => {
|
||
|
const $element = angular.element('<vn-client-unpaid></vn-client-unpaid>');
|
||
|
controller = $componentController('vnClientUnpaid', {$element, $scope});
|
||
|
}));
|
||
|
|
||
|
describe('setDefaultDate()', () => {
|
||
|
it(`should not set today date if has data`, () => {
|
||
|
const hasData = true;
|
||
|
const yesterday = new Date();
|
||
|
yesterday.setDate(yesterday.getDate() - 1);
|
||
|
|
||
|
controller.clientUnpaid = {
|
||
|
dated: yesterday
|
||
|
};
|
||
|
controller.setDefaultDate(hasData);
|
||
|
|
||
|
expect(controller.clientUnpaid.dated).toEqual(yesterday);
|
||
|
});
|
||
|
|
||
|
it(`should set today if not has data`, () => {
|
||
|
const hasData = false;
|
||
|
const today = new Date();
|
||
|
|
||
|
controller.clientUnpaid = {};
|
||
|
controller.setDefaultDate(hasData);
|
||
|
|
||
|
expect(controller.clientUnpaid.dated).toEqual(today);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|