salix/front/core/components/date-picker/index.spec.js

41 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

describe('Component vnDatePicker', () => {
let $filter;
let $element;
let $ctrl;
2019-11-11 15:32:03 +00:00
let today;
2023-01-16 14:18:24 +00:00
today = Date.vnNew();
2019-11-11 15:32:03 +00:00
today.setHours(0, 0, 0, 0);
beforeEach(ngModule('vnCore'));
2020-07-23 14:46:16 +00:00
beforeEach(inject(($compile, $rootScope, _$filter_) => {
$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;
let displayed = $filter('date')(today, 'yyyy-MM-dd');
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);
});
});
});