2019-10-08 21:57:02 +00:00
|
|
|
describe('Component vnDatePicker', () => {
|
|
|
|
let $filter;
|
|
|
|
let $element;
|
|
|
|
let $ctrl;
|
|
|
|
|
2019-11-11 15:32:03 +00:00
|
|
|
let today;
|
|
|
|
today = new Date();
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2019-10-08 21:57:02 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($compile, $rootScope, _$filter_) => {
|
2019-10-08 21:57:02 +00:00
|
|
|
$filter = _$filter_;
|
|
|
|
|
|
|
|
$element = $compile(`<vn-date-picker></vn-date-picker>`)($rootScope);
|
|
|
|
$ctrl = $element.controller('vnDatePicker');
|
|
|
|
}));
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
$element.remove();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('field() setter', () => {
|
|
|
|
it(`should display the formated the date`, () => {
|
|
|
|
$ctrl.field = today;
|
2019-10-18 23:18:25 +00:00
|
|
|
let displayed = $filter('date')(today, 'yyyy-MM-dd');
|
2019-10-08 21:57:02 +00:00
|
|
|
|
|
|
|
expect($ctrl.value).toEqual(displayed);
|
|
|
|
});
|
|
|
|
});
|
2019-11-11 15:32:03 +00:00
|
|
|
|
|
|
|
describe('onValueUpdate()', () => {
|
|
|
|
it(`should change the picker value to selected date`, () => {
|
|
|
|
$ctrl.value = $filter('date')(today, 'yyyy-MM-dd');
|
|
|
|
$ctrl.input.dispatchEvent(new Event('change'));
|
|
|
|
|
|
|
|
expect($ctrl.field).toEqual(today);
|
|
|
|
});
|
|
|
|
});
|
2019-10-08 21:57:02 +00:00
|
|
|
});
|