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('
'); 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'); }); }); });