39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
|
import './index.js';
|
||
|
|
||
|
fdescribe('Component vnInputFile', () => {
|
||
|
let $scope;
|
||
|
let $attrs;
|
||
|
let $timeout;
|
||
|
let $element;
|
||
|
let controller;
|
||
|
|
||
|
beforeEach(ngModule('vnCore'));
|
||
|
|
||
|
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
|
||
|
$scope = $rootScope.$new();
|
||
|
$attrs = {};
|
||
|
$element = angular.element('<div><input type="file"><div class="infix"><div class="rightIcons"></div></div>');
|
||
|
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');
|
||
|
});
|
||
|
});
|
||
|
});
|