Merge "[Launch Instance Fix] Add Security Group Step Unit Tests"

This commit is contained in:
Jenkins 2015-04-14 20:44:42 +00:00 committed by Gerrit Code Review
commit aa5a7c1a56
3 changed files with 94 additions and 18 deletions

View File

@ -1,4 +1,3 @@
/* jshint globalstrict: true */
/*
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
*
@ -18,6 +17,79 @@
'use strict';
describe('Launch Instance Security Groups Step', function() {
describe('LaunchInstanceSecurityGroupsCtrl', function() {
var ctrl;
beforeEach(module('hz.dashboard.launch-instance'));
beforeEach(inject(function($controller) {
var model = {
newInstanceSpec: {
security_groups: [ 'group 1' ]
},
securityGroups: [ 'group 1', 'group 2' ]
};
ctrl = $controller('LaunchInstanceSecurityGroupsCtrl',
{ launchInstanceModel: model });
}));
it('contains its general labels', function() {
expect(ctrl.label).toBeDefined();
expect(Object.keys(ctrl.label).length).toBeGreaterThan(0);
});
it('contains its table labels', function() {
expect(ctrl.tableData).toBeDefined();
expect(Object.keys(ctrl.tableData).length).toBeGreaterThan(0);
});
it('sets table data to appropriate scoped items', function() {
expect(ctrl.tableData).toBeDefined();
expect(Object.keys(ctrl.tableData).length).toBe(4);
expect(ctrl.tableData.available).toEqual([ 'group 1', 'group 2' ]);
expect(ctrl.tableData.allocated).toEqual([ 'group 1' ]);
expect(ctrl.tableData.displayedAvailable).toEqual([]);
expect(ctrl.tableData.displayedAllocated).toEqual([]);
});
it('defines table details template', function() {
expect(ctrl.tableDetails).toBeDefined();
});
it('defines table help', function() {
expect(ctrl.tableHelp).toBeDefined();
expect(Object.keys(ctrl.tableHelp).length).toBe(2);
expect(ctrl.tableHelp.noneAllocText).toBeDefined();
expect(ctrl.tableHelp.availHelpText).toBeDefined();
});
it('allows unlimited allocation', function() {
expect(ctrl.tableLimits).toBeDefined();
expect(Object.keys(ctrl.tableLimits).length).toBe(1);
expect(ctrl.tableLimits.maxAllocation).toBe(-1);
});
});
describe('LaunchInstanceSecurityGroupsHelpCtrl', function() {
var ctrl;
beforeEach(module('hz.dashboard.launch-instance'));
beforeEach(inject(function($controller) {
ctrl = $controller('LaunchInstanceSecurityGroupsHelpCtrl');
}));
it('defines the title', function() {
expect(ctrl.title).toBeDefined();
});
it('has paragraphs', function() {
expect(ctrl.paragraphs).toBeDefined();
expect(ctrl.paragraphs.length).toBeGreaterThan(0);
});
});
});
})();

View File

@ -15,7 +15,7 @@
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-cookies.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-bootstrap.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/angular/angular-sanitize.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/smart-table/smart-table.js"></script>
<script src="{{ STATIC_URL }}horizon/lib/angular/smart-table.js"></script>
<script type="text/javascript">
/* Load angular modules extensions list before we include angular/horizon.js */

View File

@ -22,25 +22,29 @@ LAUNCH_INST = "dashboard/launch-instance"
class ServicesTests(test.JasmineTests):
# sources would go here
sources = [
LAUNCH_INST + "/launch-instance.js",
LAUNCH_INST + "/launch-instance.model.js",
LAUNCH_INST + 'security-groups/security-groups.js',
LAUNCH_INST + 'keypair/keypair.js',
LAUNCH_INST + "/configuration/configuration.js",
LAUNCH_INST + "/flavor/flavor.js",
LAUNCH_INST + "/network/network.js",
LAUNCH_INST + "/source/source.js",
'dashboard/dashboard.module.js',
'dashboard/workflow/workflow.js',
LAUNCH_INST + '/launch-instance.js',
LAUNCH_INST + '/launch-instance.model.js',
LAUNCH_INST + '/security-groups/security-groups.js',
LAUNCH_INST + '/keypair/keypair.js',
LAUNCH_INST + '/configuration/configuration.js',
LAUNCH_INST + '/flavor/flavor.js',
LAUNCH_INST + '/network/network.js',
LAUNCH_INST + '/source/source.js',
]
# spec files would go here
specs = [
LAUNCH_INST + "/launch-instance.spec.js",
LAUNCH_INST + "/launch-instance.model.spec.js",
LAUNCH_INST + 'security-groups/security-groups.spec.js',
LAUNCH_INST + 'keypair/keypair.spec.js',
LAUNCH_INST + "/configuration/configuration.spec.js",
LAUNCH_INST + "/flavor/flavor.spec.js",
LAUNCH_INST + "/network/network.spec.js",
LAUNCH_INST + "/source/source.spec.js",
'dashboard/dashboard.module.js',
'dashboard/workflow/workflow.js',
LAUNCH_INST + '/launch-instance.spec.js',
LAUNCH_INST + '/launch-instance.model.spec.js',
LAUNCH_INST + '/security-groups/security-groups.spec.js',
LAUNCH_INST + '/keypair/keypair.spec.js',
LAUNCH_INST + '/configuration/configuration.spec.js',
LAUNCH_INST + '/flavor/flavor.spec.js',
LAUNCH_INST + '/network/network.spec.js',
LAUNCH_INST + '/source/source.spec.js',
]
externalTemplates = [
]