salix/front/core/components/input-file/index.spec.js

41 lines
1.4 KiB
JavaScript
Raw Normal View History

import './index.js';
2019-06-07 11:07:23 +00:00
describe('Component vnInputFile', () => {
let $scope;
let $attrs;
let $timeout;
let $element;
let controller;
2019-09-13 14:09:14 +00:00
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
2019-09-09 08:57:10 +00:00
$attrs = {field: '$ctrl.dms.file'};
2019-10-09 22:47:29 +00:00
$element = angular.element('<vn-input-file label="File" ng-model="$ctrl.dms.file"><input type="file"><div class="infix"><div class="rightIcons"></div></vn-input-file>');
controller = $componentController('vnInputFile', {$element, $scope, $attrs, $timeout, $transclude: () => {}});
controller.input = $element[0].querySelector('input');
controller.validate = () => {};
}));
describe('files() setter', () => {
it(`should set a value, and then add the class 'not-empty'`, () => {
controller.files = [{name: 'MyFile'}];
let classes = controller.element.classList.toString();
expect(classes).toContain('not-empty');
});
it(`should set an empty value, and then remove the class 'not-empty'`, () => {
controller.files = null;
let classes = controller.element.classList.toString();
expect(classes).not.toContain('not-empty');
});
});
});