44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Component vnInputTime', () => {
|
|
let $scope;
|
|
let $attrs;
|
|
let $timeout;
|
|
let $element;
|
|
let controller;
|
|
|
|
beforeEach(angular.mock.module('vnCore', $translateProvider => {
|
|
$translateProvider.translations('en', {});
|
|
}));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
|
$scope = $rootScope.$new();
|
|
$attrs = {field: '$ctrl.zone.hour'};
|
|
$element = angular.element('<vn-input-time label="Hour" field="$ctrl.zone.hour"><input><div class="infix invalid validated"><div class="rightIcons"></div></vn-input-time>');
|
|
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);
|
|
});
|
|
});
|
|
});
|