41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
import './index.js';
|
|
|
|
describe('Component vnInputFile', () => {
|
|
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.dms.file'};
|
|
$element = angular.element('<vn-input-file label="File" field="$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');
|
|
});
|
|
});
|
|
});
|