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

38 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-04-26 14:10:51 +00:00
describe('Component vnDatePicker', () => {
2019-01-16 12:33:21 +00:00
let controller;
let $attrs;
let $element;
let today = new Date();
today.setHours(0, 0, 0, 0);
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
2019-01-16 12:33:21 +00:00
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.inject(($componentController, $translate) => {
2019-01-16 12:33:21 +00:00
$attrs = {};
$element = angular.element(`<vn-date-picker><div><input type="text" class="mdl-textfield__input" name="MyName" ng-disabled="$ctrl.disabled" rule=""></input></div></vn-date-picker>`);
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);
});
});
});