41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
describe('Component vnDatePicker', () => {
|
|
let $filter;
|
|
let $element;
|
|
let $ctrl;
|
|
|
|
let today;
|
|
today = Date.vnNew();
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
beforeEach(ngModule('vnCore'));
|
|
|
|
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);
|
|
});
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|
|
});
|