2019-06-06 11:59:11 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2019-06-07 11:07:23 +00:00
|
|
|
describe('Component vnInputFile', () => {
|
2019-06-06 11:59:11 +00:00
|
|
|
let $scope;
|
|
|
|
let $attrs;
|
|
|
|
let $timeout;
|
|
|
|
let $element;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('vnCore'));
|
2019-06-06 11:59:11 +00:00
|
|
|
|
|
|
|
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>');
|
2019-06-06 11:59:11 +00:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|