describe('Component vnDatePicker', () => { let $filter; let $element; let $ctrl; let today; today = new Date(); today.setHours(0, 0, 0, 0); beforeEach(ngModule('vnCore')); beforeEach(inject(($compile, $rootScope, _$filter_) => { $filter = _$filter_; $element = $compile(``)($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); }); }); });