describe('Component vnDatePicker', () => { let $filter; let $element; let $ctrl; let today; beforeEach(angular.mock.module('vnCore', $translateProvider => { $translateProvider.translations('en', {}); })); beforeEach(angular.mock.inject(($compile, $rootScope, _$filter_) => { $filter = _$filter_; $element = $compile(``)($rootScope); $ctrl = $element.controller('vnDatePicker'); today = new Date(); today.setUTCHours(0, 0, 0, 0); })); afterEach(() => { $element.remove(); }); describe('field() setter', () => { it(`should display the formated the date`, () => { $ctrl.field = today; let displayed = $filter('dateTime')(today, 'yyyy-MM-dd'); expect($ctrl.value).toEqual(displayed); }); }); describe('options() setter', () => { it(`should display the date with the new format`, () => { $ctrl.options = {dateFormat: 'Y-m'}; $ctrl.field = today; let displayed = $filter('dateTime')(today, 'yyyy-MM'); expect($ctrl.value).toEqual(displayed); }); }); });