mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
de-lint unit tests
This commit is contained in:
@@ -3,7 +3,6 @@ describe('Components | Layout', () => {
|
|||||||
let $rootScope;
|
let $rootScope;
|
||||||
let element;
|
let element;
|
||||||
let scope;
|
let scope;
|
||||||
let i18n;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
angular.mock.module('gettext');
|
angular.mock.module('gettext');
|
||||||
@@ -26,19 +25,19 @@ describe('Components | Layout', () => {
|
|||||||
describe('AtLayoutController', () => {
|
describe('AtLayoutController', () => {
|
||||||
let controller;
|
let controller;
|
||||||
|
|
||||||
beforeEach(()=> {
|
beforeEach(() => {
|
||||||
controller = element.controller('atLayout');
|
controller = element.controller('atLayout');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('$scope.$on($stateChangeSuccess) should assign toState name to currentState', () => {
|
it('$scope.$on($stateChangeSuccess) should assign toState name to currentState', () => {
|
||||||
let next = {'name': 'dashboard'};
|
const next = { name: 'dashboard' };
|
||||||
$rootScope.$broadcast('$stateChangeSuccess', next);
|
$rootScope.$broadcast('$stateChangeSuccess', next);
|
||||||
expect(controller.currentState).toBe('dashboard');
|
expect(controller.currentState).toBe('dashboard');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('$root.current_user watcher should assign value to ', () => {
|
describe('$root.current_user watcher should assign value to ', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
let val = {
|
const val = {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
id: 1
|
id: 1
|
||||||
};
|
};
|
||||||
@@ -89,11 +88,10 @@ describe('Components | Layout', () => {
|
|||||||
expect(controller.currentUserId).toBeTruthy();
|
expect(controller.currentUserId).toBeTruthy();
|
||||||
expect(controller.currentUserId).toBe(1);
|
expect(controller.currentUserId).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('$root.socketStatus watcher should assign newStatus to', () => {
|
describe('$root.socketStatus watcher should assign newStatus to', () => {
|
||||||
let statuses = ['connecting', 'error', 'ok'];
|
const statuses = ['connecting', 'error', 'ok'];
|
||||||
|
|
||||||
it('socketState', () => {
|
it('socketState', () => {
|
||||||
_.forEach(statuses, (status) => {
|
_.forEach(statuses, (status) => {
|
||||||
@@ -128,7 +126,7 @@ describe('Components | Layout', () => {
|
|||||||
describe('getString()', () => {
|
describe('getString()', () => {
|
||||||
it('calls ComponentsStrings get() method', angular.mock.inject((_ComponentsStrings_) => {
|
it('calls ComponentsStrings get() method', angular.mock.inject((_ComponentsStrings_) => {
|
||||||
spyOn(_ComponentsStrings_, 'get');
|
spyOn(_ComponentsStrings_, 'get');
|
||||||
controller.getString('VIEW_DOCS')
|
controller.getString('VIEW_DOCS');
|
||||||
expect(_ComponentsStrings_.get).toHaveBeenCalled();
|
expect(_ComponentsStrings_.get).toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -137,7 +135,7 @@ describe('Components | Layout', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return layout string', () => {
|
it('should return layout string', () => {
|
||||||
let layoutStrings = {
|
const layoutStrings = {
|
||||||
CURRENT_USER_LABEL: 'Logged in as',
|
CURRENT_USER_LABEL: 'Logged in as',
|
||||||
VIEW_DOCS: 'View Documentation',
|
VIEW_DOCS: 'View Documentation',
|
||||||
LOGOUT: 'Logout',
|
LOGOUT: 'Logout',
|
||||||
@@ -149,8 +147,8 @@ describe('Components | Layout', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return default string', () => {
|
it('should return default string', () => {
|
||||||
let defaultStrings = {
|
const defaultStrings = {
|
||||||
BRAND_NAME: "AWX"
|
BRAND_NAME: 'AWX'
|
||||||
};
|
};
|
||||||
|
|
||||||
_.forEach(defaultStrings, (value, key) => {
|
_.forEach(defaultStrings, (value, key) => {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ describe('Components | Side Nav Item', () => {
|
|||||||
angular.mock.module('gettext');
|
angular.mock.module('gettext');
|
||||||
angular.mock.module('I18N');
|
angular.mock.module('I18N');
|
||||||
angular.mock.module('ui.router');
|
angular.mock.module('ui.router');
|
||||||
angular.mock.module('at.lib.services')
|
angular.mock.module('at.lib.services');
|
||||||
angular.mock.module('at.lib.components')
|
angular.mock.module('at.lib.components');
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(angular.mock.inject((_$compile_, _$rootScope_) => {
|
beforeEach(angular.mock.inject((_$compile_, _$rootScope_) => {
|
||||||
@@ -24,7 +24,6 @@ describe('Components | Side Nav Item', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Side Nav Item Controller', () => {
|
describe('Side Nav Item Controller', () => {
|
||||||
let LayoutCtrl;
|
|
||||||
let SideNavItem;
|
let SideNavItem;
|
||||||
let SideNavItemCtrl;
|
let SideNavItemCtrl;
|
||||||
|
|
||||||
@@ -34,12 +33,12 @@ describe('Components | Side Nav Item', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('layoutVm.currentState watcher should assign isRoute', () => {
|
it('layoutVm.currentState watcher should assign isRoute', () => {
|
||||||
let current = {'name': 'dashboard'};
|
let current = { name: 'dashboard' };
|
||||||
$rootScope.$broadcast('$stateChangeSuccess', current);
|
$rootScope.$broadcast('$stateChangeSuccess', current);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
expect(SideNavItemCtrl.isRoute).toBe(true);
|
expect(SideNavItemCtrl.isRoute).toBe(true);
|
||||||
|
|
||||||
current = {'name': 'inventories'};
|
current = { name: 'inventories' };
|
||||||
$rootScope.$broadcast('$stateChangeSuccess', current);
|
$rootScope.$broadcast('$stateChangeSuccess', current);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
expect(SideNavItemCtrl.isRoute).toBe(false);
|
expect(SideNavItemCtrl.isRoute).toBe(false);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ describe('Components | Side Nav', () => {
|
|||||||
let $rootScope;
|
let $rootScope;
|
||||||
let element;
|
let element;
|
||||||
let scope;
|
let scope;
|
||||||
let windowMock = {
|
const windowMock = {
|
||||||
innerWidth: 500
|
innerWidth: 500
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ describe('Components | Side Nav', () => {
|
|||||||
angular.mock.module('gettext');
|
angular.mock.module('gettext');
|
||||||
angular.mock.module('I18N');
|
angular.mock.module('I18N');
|
||||||
angular.mock.module('ui.router');
|
angular.mock.module('ui.router');
|
||||||
angular.mock.module('at.lib.services')
|
angular.mock.module('at.lib.services');
|
||||||
angular.mock.module('at.lib.components', ($provide) => {
|
angular.mock.module('at.lib.components', ($provide) => {
|
||||||
$provide.value('$window', windowMock);
|
$provide.value('$window', windowMock);
|
||||||
});
|
});
|
||||||
@@ -22,7 +22,7 @@ describe('Components | Side Nav', () => {
|
|||||||
$rootScope = _$rootScope_;
|
$rootScope = _$rootScope_;
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
|
|
||||||
element = angular.element("<at-layout><at-side-nav></at-side-nav><at-layout>");
|
element = angular.element('<at-layout><at-side-nav></at-side-nav><at-layout>');
|
||||||
element = $compile(element)(scope);
|
element = $compile(element)(scope);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
}));
|
}));
|
||||||
@@ -59,8 +59,8 @@ describe('Components | Side Nav', () => {
|
|||||||
it('isExpanded should be false after state change event', () => {
|
it('isExpanded should be false after state change event', () => {
|
||||||
sideNavCtrl.isExpanded = true;
|
sideNavCtrl.isExpanded = true;
|
||||||
|
|
||||||
let current = {
|
const current = {
|
||||||
'name': 'dashboard'
|
name: 'dashboard'
|
||||||
};
|
};
|
||||||
$rootScope.$broadcast('$stateChangeSuccess', current);
|
$rootScope.$broadcast('$stateChangeSuccess', current);
|
||||||
scope.$digest();
|
scope.$digest();
|
||||||
|
|||||||
Reference in New Issue
Block a user