describe('Component vnDatePicker', () => { let controller; let $attrs; let $element; let today = new Date(); today.setHours(0, 0, 0, 0); beforeEach(angular.mock.module('vnCore', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(angular.mock.inject(($componentController, $translate) => { $attrs = {}; $element = angular.element(`
`); controller = $componentController('vnDatePicker', {$element, $attrs, $translate}); })); describe('onValueUpdate() while date is selected', () => { it(`should store the selected date in the controller`, () => { controller.vp = {selectedDates: [today]}; controller.isLocale = true; controller.onValueUpdate(); expect(controller._model).toEqual(today); }); it(`should format the date`, () => { controller.vp = {selectedDates: [today], destroy: () => {}}; controller.isLocale = undefined; controller._iniOptions.enableTime = undefined; controller.onValueUpdate(); expect(controller._model).toEqual(today); }); }); });