mirror of
https://github.com/ZwareBear/awx.git
synced 2026-05-14 05:28:37 -05:00
Refactor UI Build System (#3203)
* initial build trial, clean up awx/ui * fix hardcoded refs to ng-toast, add jshint preloader * remove browserify test * update grunt-jshint -> jshint module loader, browser-sync, update dev targets to build-docker-machine & build-docker-cid, fix blocking tasks * less autoprefixer * sample build commands * fix release build * update README * karma config stub * webpack config for karma tests * karma preview for shane * fix build-docker-machine target * karma+webpack test pipeline configuration, stub tests * fix smart/job status icons classes * fix jquery + jsyaml shims, fix LESS cascade * fix angular-codemirror dependency, explicitly import style/mode dependencies * shim jsonlint * fix angular-scheduler AMD imports, remove jquuery-ui shim, fix release config * use closed $.fn.datepicker for system-tracking * remove packaging/node/ * remove old tests * shrinkwrap fragile dependency sandcastle, update README, lint * first pass at fixing rrule shim * update makefile targets * update gitignore w/ new flag file * add saucelabs karma config * add license controller test * add examples of service and directive tests * Makefile flubs * consolidate clean-ui target, compulsively update flag file location * dep on CJS/AMD/UMD compatible version of rrule lib, fix example tests/config for demo * boilerplate karma config for saucelabs (should be abstracted to common config after proven to work) * update docs * docs feedback * update Dockerfile with Node 6.x dep
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
describe('Directive: Features enabled/disabled', () => {
|
||||
let $compile,
|
||||
$scope;
|
||||
|
||||
beforeEach(angular.mock.module('features'));
|
||||
|
||||
beforeEach(angular.mock.inject((_$compile_, _$rootScope_) => {
|
||||
$compile = _$compile_;
|
||||
$scope = _$rootScope_;
|
||||
}));
|
||||
|
||||
it('Removes the element if feature is disabled', () => {
|
||||
let element = $compile("<div aw-feature='system-tracking'></div")($scope);
|
||||
$scope.$digest();
|
||||
expect(element.html()).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
describe('Service: InventoryManageService', () => {
|
||||
|
||||
let Rest,
|
||||
InventoryManageService;
|
||||
|
||||
beforeEach(angular.mock.module('Tower'), ($provide)=>{
|
||||
$provide.value('Rest', Rest);
|
||||
});
|
||||
beforeEach(angular.mock.module('inventoryManage'));
|
||||
beforeEach(angular.mock.inject(($httpBackend, _InventoryManageService_) =>{
|
||||
Rest = $httpBackend;
|
||||
InventoryManageService = _InventoryManageService_;
|
||||
}));
|
||||
|
||||
xdescribe('RESTy methods should handle errors', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(InventoryManageService, 'error');
|
||||
});
|
||||
it('InventoryManageService.getInventory should handle errors', () => {
|
||||
Rest.expectGET('/api/v1/inventory:id/').respond(400, {});
|
||||
Rest.flush();
|
||||
expect(InventoryManageService.error).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
// Unit tests often reveal which pieces of our code should be factored out
|
||||
xit('RESTy methods should start/stop spinny', function(){
|
||||
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
Rest.verifyNoOutstandingExpectation();
|
||||
Rest.verifyNoOutstandingRequest();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
describe('Controller: LicenseController', () => {
|
||||
// Setup
|
||||
let scope,
|
||||
LicenseController,
|
||||
ConfigService,
|
||||
ProcessErrors;
|
||||
|
||||
beforeEach(angular.mock.module('Tower'));
|
||||
beforeEach(angular.mock.module('license', ($provide) => {
|
||||
ConfigService = jasmine.createSpyObj('ConfigService', [
|
||||
'getConfig',
|
||||
'delete'
|
||||
]);
|
||||
|
||||
ConfigService.getConfig.and.returnValue({
|
||||
then: function(callback){
|
||||
return callback({
|
||||
license_info: {
|
||||
time_remaining: 1234567 // seconds
|
||||
},
|
||||
version: '3.1.0-devel'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ProcessErrors = jasmine.createSpy('ProcessErrors');
|
||||
|
||||
$provide.value('ConfigService', ConfigService);
|
||||
$provide.value('ProcessErrors', ProcessErrors);
|
||||
}));
|
||||
|
||||
beforeEach(angular.mock.inject( ($rootScope, $controller, _ConfigService_, _ProcessErrors_) => {
|
||||
scope = $rootScope.$new();
|
||||
ConfigService = _ConfigService_;
|
||||
ProcessErrors = _ProcessErrors_;
|
||||
LicenseController = $controller('licenseController', {
|
||||
$scope: scope,
|
||||
ConfigService: ConfigService,
|
||||
ProcessErrors: ProcessErrors
|
||||
});
|
||||
}));
|
||||
|
||||
// Suites
|
||||
it('should GET a config object on initialization', ()=>{
|
||||
expect(ConfigService.getConfig).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should show correct expiration date', ()=>{
|
||||
let date = new Date(),
|
||||
options = {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit'
|
||||
};
|
||||
date.setDate(date.getDate() + 14);
|
||||
expect(scope.time.expiresOn).toEqual(date.toLocaleDateString(undefined, options));
|
||||
});
|
||||
|
||||
it('should show correct time remaining', ()=>{
|
||||
expect(scope.time.remaining).toMatch('14 Days');
|
||||
});
|
||||
|
||||
xit('should throw an error if provided license is invalid JSON', ()=>{
|
||||
let event = {
|
||||
target: {files: [new File(['asdf'], 'license.txt', {type: 'text/html'})]}
|
||||
};
|
||||
scope.getKey(event);
|
||||
expect(ProcessErrors).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
xit('should submit a valid license');
|
||||
});
|
||||
Reference in New Issue
Block a user