import './index.js'; describe('Component vnInputTime', () => { let $scope; let $attrs; let $timeout; let $element; let controller; beforeEach(ngModule('vnCore')); beforeEach(angular.mock.inject(($componentController, $rootScope) => { $scope = $rootScope.$new(); $attrs = {field: '$ctrl.zone.hour'}; $element = angular.element('
'); controller = $componentController('vnInputTime', {$element, $scope, $attrs, $timeout, $transclude: () => {}}); })); describe('value() setter', () => { it(`should set _value to a given value, add the class not-empty and remove invalid and validated`, () => { const today = new Date(); controller.value = today; let classes = controller.element.classList.toString(); expect(classes).toContain('not-empty'); expect(controller._value).toEqual(today); classes = controller.element.querySelector('.infix').classList.toString(); expect(classes).not.toContain('invalid validated'); }); it(`should set _value to a given value and not add the class not-empty if the given value is null`, () => { controller.value = null; let classes = controller.element.classList.toString(); expect(classes).not.toContain('not-empty'); expect(controller._value).toEqual(null); }); }); describe('step() setter/getter', () => { it(`should set input.step to a given value`, () => { controller.step = 2; expect(controller.input.step).toEqual('2'); }); it(`should return a number`, () => { controller.step = 2; expect(controller.step).toEqual(2); expect(typeof controller.step).toEqual('number'); }); }); });