diff --git a/awx/ui/client/lib/components/input/file.directive.js b/awx/ui/client/lib/components/input/file.directive.js
index bdc7b8ecde71..42aa2c4fba1c 100644
--- a/awx/ui/client/lib/components/input/file.directive.js
+++ b/awx/ui/client/lib/components/input/file.directive.js
@@ -21,7 +21,7 @@ function AtInputFileController (baseInputController, eventService) {
baseInputController.call(vm, 'input', _scope_, element, form);
scope = _scope_;
- [input] = element.find('input');
+ input = element.find('input')[0]; // eslint-disable-line prefer-destructuring
vm.listeners = vm.setFileListeners(input);
diff --git a/awx/ui/client/lib/components/modal/modal.directive.js b/awx/ui/client/lib/components/modal/modal.directive.js
index f6e5510ce573..e1d1126121b6 100644
--- a/awx/ui/client/lib/components/modal/modal.directive.js
+++ b/awx/ui/client/lib/components/modal/modal.directive.js
@@ -22,8 +22,8 @@ function AtModalController (eventService, strings) {
vm.strings = strings;
vm.init = (scope, el) => {
- [overlay] = el;
- [modal] = el.find('.at-Modal-window');
+ overlay = el[0]; // eslint-disable-line prefer-destructuring
+ modal = el.find('.at-Modal-window')[0]; // eslint-disable-line prefer-destructuring
vm.modal = scope[scope.ns].modal;
vm.modal.show = vm.show;
diff --git a/awx/ui/test/unit/components/file.unit.js b/awx/ui/test/unit/components/file.unit.js
new file mode 100644
index 000000000000..1bf7041b56fd
--- /dev/null
+++ b/awx/ui/test/unit/components/file.unit.js
@@ -0,0 +1,61 @@
+describe('Components | Input | File', () => {
+ let $scope;
+ let element;
+ let state;
+ let controller;
+
+ const getMockFileEvent = file => ({ target: { files: [file] } });
+
+ beforeEach(() => {
+ angular.mock.module('at.lib.services');
+ angular.mock.module('at.lib.components');
+ });
+
+ describe('AtInputFileController', () => {
+ beforeEach(angular.mock.inject(($rootScope, $compile) => {
+ const component = '';
+ const dom = angular.element(`${component}`);
+
+ $scope = $rootScope.$new();
+ $scope.vm = { form: { disabled: false, unit: {} } };
+
+ $compile(dom)($scope);
+ $scope.$digest();
+
+ element = dom.find('#unit');
+ state = $scope.vm.form.unit;
+ controller = element.controller('atInputFile');
+ }));
+
+ it('should initialize without a value by default', () => {
+ expect(state._value).not.toBeDefined();
+ expect(state._displayValue).not.toBeDefined();
+ });
+
+ it('should update display value with file name when file is read', () => {
+ const name = 'notavirus.exe';
+ const reader = { result: 'AAAAAAA' };
+
+ controller.check = jasmine.createSpy('check');
+
+ controller.readFile(reader, getMockFileEvent({ name }));
+
+ $scope.$digest();
+
+ expect(state._value).toBeDefined();
+ expect(state._displayValue).toEqual(name);
+
+ expect(controller.check).toHaveBeenCalled();
+ });
+
+ it('should notify handler on file input change event', () => {
+ controller.handleFileChangeEvent = jasmine.createSpy('handleFileChangeEvent');
+
+ element.find('input')[0].dispatchEvent(new Event('change'));
+
+ $scope.$digest();
+
+ expect(controller.handleFileChangeEvent).toHaveBeenCalled();
+ });
+ });
+});
diff --git a/awx/ui/test/unit/components/index.js b/awx/ui/test/unit/components/index.js
index 398445bc6f3e..8d75e3cf7153 100644
--- a/awx/ui/test/unit/components/index.js
+++ b/awx/ui/test/unit/components/index.js
@@ -2,6 +2,7 @@
import 'angular-mocks';
// Import tests
+import './file.unit';
import './layout.unit';
import './side-nav.unit';
import './side-nav-item.unit';