diff --git a/horizon/static/angular/charts/pie-chart.spec.js b/horizon/static/angular/charts/pie-chart.spec.js index 839829e7fa..7bfcfbd5c6 100644 --- a/horizon/static/angular/charts/pie-chart.spec.js +++ b/horizon/static/angular/charts/pie-chart.spec.js @@ -1,88 +1,90 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ -describe('hz.widget.charts module', function () { - it('should be defined', function () { - expect(angular.module('hz.widget.charts')).toBeDefined(); - }); -}); + 'use strict'; -describe('pie chart directive', function() { - - var $scope, $element; - - beforeEach(module('templates')); - beforeEach(module('hz')); - beforeEach(module('hz.widgets')); - beforeEach(module('hz.widget.charts')); - - beforeEach(inject(function($injector) { - var $compile = $injector.get('$compile'); - $scope = $injector.get('$rootScope').$new(); - - $scope.testData = { - title: 'Total Instances', - label: '25%', - data: [ - { label: 'Current', value: 1, color: '#1f83c6' }, - { label: 'Added', value: 1, color: '#81c1e7' }, - { label: 'Remaining', value: 6, color: '#d1d3d4', hideKey: true } - ] - }; - - var settings = '{ "innerRadius": 25 }'; - var markup = ""; - $element = angular.element(markup); - $compile($element)($scope); - - $scope.$digest(); - })); - - it('should be compiled', function() { - expect($element.html().trim()).not.toBe(''); + describe('hz.widget.charts module', function () { + it('should be defined', function () { + expect(angular.module('hz.widget.charts')).toBeDefined(); + }); }); - it('should have svg element', function() { - expect($element.find('svg')).toBeDefined(); + describe('pie chart directive', function() { + + var $scope, $element; + + beforeEach(module('templates')); + beforeEach(module('hz')); + beforeEach(module('hz.widgets')); + beforeEach(module('hz.widget.charts')); + + beforeEach(inject(function($injector) { + var $compile = $injector.get('$compile'); + $scope = $injector.get('$rootScope').$new(); + + $scope.testData = { + title: 'Total Instances', + label: '25%', + data: [ + { label: 'Current', value: 1, color: '#1f83c6' }, + { label: 'Added', value: 1, color: '#81c1e7' }, + { label: 'Remaining', value: 6, color: '#d1d3d4', hideKey: true } + ] + }; + + var settings = '{ "innerRadius": 25 }'; + var markup = ""; + $element = angular.element(markup); + $compile($element)($scope); + + $scope.$digest(); + })); + + it('should be compiled', function() { + expect($element.html().trim()).not.toBe(''); + }); + + it('should have svg element', function() { + expect($element.find('svg')).toBeDefined(); + }); + + it('should have 3 path elements', function() { + expect($element.find('path.slice').length).toBe(3); + }); + + it('should have correct colors for slices', function() { + var slices = $element.find('path.slice'); + + var slice1Color = slices[0].style.fill; + + if (slice1Color.indexOf('rgb') === 0) { + expect(slices[0].style.fill).toBe('rgb(31, 131, 198)'); + expect(slices[1].style.fill).toBe('rgb(129, 193, 231)'); + expect(slices[2].style.fill).toBe('rgb(209, 211, 212)'); + } else { + expect(slices[0].style.fill).toBe('#1f83c6'); + expect(slices[1].style.fill).toBe('#81c1e7'); + expect(slices[2].style.fill).toBe('#d1d3d4'); + } + }); + + it('should have a correct title "Total Instances (8 Max)"', function() { + var title = $element.find('.pie-chart-title').text().trim(); + expect(title).toBe('Total Instances (8 Max)'); + }); + + it('should have a legend', function() { + expect($element.find('.pie-chart-legend')).toBeDefined(); + }); + + it ('should have correct legend keys and labels', function() { + var legendKeys = $element.find('.pie-chart-legend .slice-legend'); + + var firstKeyLabel = legendKeys[0]; + var secondKeyLabel = legendKeys[1]; + + expect(firstKeyLabel.textContent.trim()).toBe('1 Current'); + expect(secondKeyLabel.textContent.trim()).toBe('1 Added'); + }); + }); - - it('should have 3 path elements', function() { - expect($element.find('path.slice').length).toBe(3); - }); - - it('should have correct colors for slices', function() { - var slices = $element.find('path.slice'); - - var slice1Color = slices[0].style.fill; - - if (slice1Color.indexOf('rgb') === 0) { - expect(slices[0].style.fill).toBe('rgb(31, 131, 198)'); - expect(slices[1].style.fill).toBe('rgb(129, 193, 231)'); - expect(slices[2].style.fill).toBe('rgb(209, 211, 212)'); - } else { - expect(slices[0].style.fill).toBe('#1f83c6'); - expect(slices[1].style.fill).toBe('#81c1e7'); - expect(slices[2].style.fill).toBe('#d1d3d4'); - } - }); - - it('should have a correct title "Total Instances (8 Max)"', function() { - var title = $element.find('.pie-chart-title').text().trim(); - expect(title).toBe('Total Instances (8 Max)'); - }); - - it('should have a legend', function() { - expect($element.find('.pie-chart-legend')).toBeDefined(); - }); - - it ('should have correct legend keys and labels', function() { - var legendKeys = $element.find('.pie-chart-legend .slice-legend'); - - var firstKeyLabel = legendKeys[0]; - var secondKeyLabel = legendKeys[1]; - - expect(firstKeyLabel.textContent.trim()).toBe('1 Current'); - expect(secondKeyLabel.textContent.trim()).toBe('1 Added'); - }); - -}); \ No newline at end of file +})(); \ No newline at end of file diff --git a/horizon/static/angular/form/form.spec.js b/horizon/static/angular/form/form.spec.js index fcb7447c84..62c8bab01a 100644 --- a/horizon/static/angular/form/form.spec.js +++ b/horizon/static/angular/form/form.spec.js @@ -1,93 +1,94 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; -describe('hz.widget.form module', function(){ - it('should have been defined', function(){ - expect(angular.module('hz.widget.form')).toBeDefined(); + describe('hz.widget.form module', function(){ + it('should have been defined', function(){ + expect(angular.module('hz.widget.form')).toBeDefined(); + }); }); -}); -describe('form directives', function() { - beforeEach(module('hz')); - beforeEach(module('hz.widgets')); - beforeEach(module('hz.widget.form')); + describe('form directives', function() { + beforeEach(module('hz')); + beforeEach(module('hz.widgets')); + beforeEach(module('hz.widget.form')); - describe('hzPasswordMatch directive', function() { + describe('hzPasswordMatch directive', function() { - var $compile, $rootScope; - var element, password, cpassword; - var markup = - '
' + - '' + - '' + - '
'; + var $compile, $rootScope; + var element, password, cpassword; + var markup = + '
' + + '' + + '' + + '
'; - beforeEach(inject(function($injector){ - $compile = $injector.get('$compile'); - $rootScope = $injector.get('$rootScope').$new(); + beforeEach(inject(function($injector){ + $compile = $injector.get('$compile'); + $rootScope = $injector.get('$rootScope').$new(); - // generate dom from markup - element = $compile(markup)($rootScope); - password = element.children('input[name]'); - cpassword = element.children('input[hz-password-match]'); + // generate dom from markup + element = $compile(markup)($rootScope); + password = element.children('input[name]'); + cpassword = element.children('input[hz-password-match]'); - // setup up initial data - $rootScope.user = {}; - $rootScope.$digest(); - })); + // setup up initial data + $rootScope.user = {}; + $rootScope.$digest(); + })); - it('should be initially empty', function() { - expect(password.val()).toEqual(''); - expect(password.val()).toEqual(cpassword.val()); - expect(cpassword.hasClass('ng-valid')).toBe(true); - }); - - it('should not match if user changes only password', function(done) { - $rootScope.user.password = 'password'; - $rootScope.$digest(); - cpassword.change(); - setTimeout(function(){ - expect(cpassword.val()).not.toEqual(password.val()); - expect(cpassword.hasClass('ng-invalid')).toBe(true); - done(); - }, 1000); - }); - - it('should not match if user changes only confirmation password', function(done) { - $rootScope.user.cpassword = 'password'; - $rootScope.$digest(); - cpassword.change(); - setTimeout(function(){ - expect(cpassword.val()).not.toEqual(password.val()); - expect(cpassword.hasClass('ng-invalid')).toBe(true); - done(); - }, 1000); - }); - - it('should match if both passwords are the same', function(done) { - $rootScope.user.password = 'password'; - $rootScope.user.cpassword = 'password'; - $rootScope.$digest(); - cpassword.change(); - setTimeout(function(){ - expect(cpassword.val()).toEqual(password.val()); + it('should be initially empty', function() { + expect(password.val()).toEqual(''); + expect(password.val()).toEqual(cpassword.val()); expect(cpassword.hasClass('ng-valid')).toBe(true); - done(); - }, 1000); - }); + }); - it('should not match if both passwords are different', function(done) { - $rootScope.user.password = 'password123'; - $rootScope.user.cpassword = 'password345'; - $rootScope.$digest(); - cpassword.change(); - setTimeout(function(){ - expect(cpassword.val()).not.toEqual(password.val()); - expect(cpassword.hasClass('ng-invalid')).toBe(true); - done(); - }, 1000); - }); + it('should not match if user changes only password', function(done) { + $rootScope.user.password = 'password'; + $rootScope.$digest(); + cpassword.change(); + setTimeout(function(){ + expect(cpassword.val()).not.toEqual(password.val()); + expect(cpassword.hasClass('ng-invalid')).toBe(true); + done(); + }, 1000); + }); - }); // end of hzPasswordMatch directive -}); // end of form directives + it('should not match if user changes only confirmation password', function(done) { + $rootScope.user.cpassword = 'password'; + $rootScope.$digest(); + cpassword.change(); + setTimeout(function(){ + expect(cpassword.val()).not.toEqual(password.val()); + expect(cpassword.hasClass('ng-invalid')).toBe(true); + done(); + }, 1000); + }); + + it('should match if both passwords are the same', function(done) { + $rootScope.user.password = 'password'; + $rootScope.user.cpassword = 'password'; + $rootScope.$digest(); + cpassword.change(); + setTimeout(function(){ + expect(cpassword.val()).toEqual(password.val()); + expect(cpassword.hasClass('ng-valid')).toBe(true); + done(); + }, 1000); + }); + + it('should not match if both passwords are different', function(done) { + $rootScope.user.password = 'password123'; + $rootScope.user.cpassword = 'password345'; + $rootScope.$digest(); + cpassword.change(); + setTimeout(function(){ + expect(cpassword.val()).not.toEqual(password.val()); + expect(cpassword.hasClass('ng-invalid')).toBe(true); + done(); + }, 1000); + }); + + }); // end of hzPasswordMatch directive + }); // end of form directives +})(); \ No newline at end of file diff --git a/horizon/static/angular/help-panel/help-panel.spec.js b/horizon/static/angular/help-panel/help-panel.spec.js index c6cec43151..66727e711c 100644 --- a/horizon/static/angular/help-panel/help-panel.spec.js +++ b/horizon/static/angular/help-panel/help-panel.spec.js @@ -1,48 +1,49 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; -describe('hz.widget.help-panel module', function() { - it('should have been defined', function () { - expect(angular.module('hz.widget.help-panel')).toBeDefined(); - }); -}); - -describe('help-panel directive', function () { - var $compile, - $scope, - element; - - beforeEach(module('templates')); - beforeEach(module('hz')); - beforeEach(module('hz.widgets')); - beforeEach(module('hz.widget.help-panel')); - beforeEach(inject(function ($injector) { - $scope = $injector.get('$rootScope').$new(); - $compile = $injector.get('$compile'); - element = $compile('Help')($scope); - $scope.$digest(); - })); - - it('should be compiled', function () { - expect(element.html().trim()).not.toBe('Help'); - expect(element.text().trim()).toBe('Help'); + describe('hz.widget.help-panel module', function() { + it('should have been defined', function () { + expect(angular.module('hz.widget.help-panel')).toBeDefined(); + }); }); - it('should be closed by default', function () { - expect(element[0].querySelector('.help-panel').className).toBe('help-panel'); - }); + describe('help-panel directive', function () { + var $compile, + $scope, + element; - it('should add "open" to class name if $scope.openHelp===true', function () { - $scope.openHelp = true; - $scope.$digest(); - expect(element[0].querySelector('.help-panel').className).toBe('help-panel open'); - }); + beforeEach(module('templates')); + beforeEach(module('hz')); + beforeEach(module('hz.widgets')); + beforeEach(module('hz.widget.help-panel')); + beforeEach(inject(function ($injector) { + $scope = $injector.get('$rootScope').$new(); + $compile = $injector.get('$compile'); + element = $compile('Help')($scope); + $scope.$digest(); + })); - it('should remove "open" from class name if $scope.openHelp===false', function () { - $scope.openHelp = true; - $scope.$digest(); - $scope.openHelp = false; - $scope.$digest(); - expect(element[0].querySelector('.help-panel').className).toBe('help-panel'); + it('should be compiled', function () { + expect(element.html().trim()).not.toBe('Help'); + expect(element.text().trim()).toBe('Help'); + }); + + it('should be closed by default', function () { + expect(element[0].querySelector('.help-panel').className).toBe('help-panel'); + }); + + it('should add "open" to class name if $scope.openHelp===true', function () { + $scope.openHelp = true; + $scope.$digest(); + expect(element[0].querySelector('.help-panel').className).toBe('help-panel open'); + }); + + it('should remove "open" from class name if $scope.openHelp===false', function () { + $scope.openHelp = true; + $scope.$digest(); + $scope.openHelp = false; + $scope.$digest(); + expect(element[0].querySelector('.help-panel').className).toBe('help-panel'); + }); }); -}); +})(); \ No newline at end of file diff --git a/horizon/static/angular/login/login.spec.js b/horizon/static/angular/login/login.spec.js index 8aa549e607..e9f4606b1c 100644 --- a/horizon/static/angular/login/login.spec.js +++ b/horizon/static/angular/login/login.spec.js @@ -14,153 +14,154 @@ * under the License. */ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; -describe('hzLoginCtrl', function(){ + describe('hzLoginCtrl', function(){ - var $controller; + var $controller; - beforeEach(module('hz')); - beforeEach(inject(function(_$controller_){ - $controller = _$controller_; - })); + beforeEach(module('hz')); + beforeEach(inject(function(_$controller_){ + $controller = _$controller_; + })); - describe('$scope.auth_type', function(){ - it('should initialize to credentials', function(){ - var scope = {}; - $controller('hzLoginCtrl', { $scope: scope }); - expect(scope.auth_type).toEqual('credentials'); - }); - }); - -}); - -describe('hzLoginFinder', function(){ - - var $compile, $rootScope, $timeout; - - var websso_markup = - '
' + - '

Some help text.

' + - '
' + - '
' + - '' + - '
' + - '
' + - '
' + - '
' + - '
'; - - var regular_markup = - '
' + - '

Some help text.

' + - '
' + - '
' + - '
' + - '
' + - '
'; - - beforeEach(module('hz')); - beforeEach(inject(function(_$compile_, _$rootScope_, _$timeout_){ - $compile = _$compile_; - $rootScope = _$rootScope_; - $timeout = _$timeout_; - - jasmine.addMatchers({ - // jquery show is not consistent across different browsers - // on FF, it is 'block' while on chrome it is 'inline' - // to reconcile this difference, we need a custom matcher - toBeVisible: function(){ - return { - compare: function(actual){ - var pass = (actual.css('display') !== 'none'); - var result = { - pass: pass, - message: pass? - 'Expected element to be visible': - 'Expected element to be visible, but it is hidden' - }; - return result; - } - }; - } - }); - })); - - describe('when websso is not enabled', function(){ - - var element, - helpText, authType, - userInput, passwordInput; - - beforeEach(function(){ - element = $compile(regular_markup)($rootScope); - authType = element.find('#id_auth_type'); - userInput = element.find("#id_username").parents('.form-group'); - passwordInput = element.find("#id_password").parents('.form-group'); - helpText = element.find('#help_text'); - $rootScope.$digest(); - }); - - it('should not contain auth_type select input', function(){ - expect(authType.length).toEqual(0); - }); - - it('should hide help text', function(){ - expect(helpText).not.toBeVisible(); - }); - - it('should show username and password inputs', function(){ - expect(userInput).toBeVisible(); - expect(passwordInput).toBeVisible(); + describe('$scope.auth_type', function(){ + it('should initialize to credentials', function(){ + var scope = {}; + $controller('hzLoginCtrl', { $scope: scope }); + expect(scope.auth_type).toEqual('credentials'); + }); }); }); - describe('when websso is enabled', function(){ + describe('hzLoginFinder', function(){ - var element, - helpText, authType, - userInput, passwordInput; + var $compile, $rootScope, $timeout; + + var websso_markup = + '
' + + '

Some help text.

' + + '
' + + '
' + + '' + + '
' + + '
' + + '
' + + '
' + + '
'; + + var regular_markup = + '
' + + '

Some help text.

' + + '
' + + '
' + + '
' + + '
' + + '
'; + + beforeEach(module('hz')); + beforeEach(inject(function(_$compile_, _$rootScope_, _$timeout_){ + $compile = _$compile_; + $rootScope = _$rootScope_; + $timeout = _$timeout_; + + jasmine.addMatchers({ + // jquery show is not consistent across different browsers + // on FF, it is 'block' while on chrome it is 'inline' + // to reconcile this difference, we need a custom matcher + toBeVisible: function(){ + return { + compare: function(actual){ + var pass = (actual.css('display') !== 'none'); + var result = { + pass: pass, + message: pass? + 'Expected element to be visible': + 'Expected element to be visible, but it is hidden' + }; + return result; + } + }; + } + }); + })); + + describe('when websso is not enabled', function(){ + + var element, + helpText, authType, + userInput, passwordInput; + + beforeEach(function(){ + element = $compile(regular_markup)($rootScope); + authType = element.find('#id_auth_type'); + userInput = element.find("#id_username").parents('.form-group'); + passwordInput = element.find("#id_password").parents('.form-group'); + helpText = element.find('#help_text'); + $rootScope.$digest(); + }); + + it('should not contain auth_type select input', function(){ + expect(authType.length).toEqual(0); + }); + + it('should hide help text', function(){ + expect(helpText).not.toBeVisible(); + }); + + it('should show username and password inputs', function(){ + expect(userInput).toBeVisible(); + expect(passwordInput).toBeVisible(); + }); - beforeEach(function(){ - element = $compile(websso_markup)($rootScope); - authType = element.find('#id_auth_type'); - userInput = element.find("#id_username").parents('.form-group'); - passwordInput = element.find("#id_password").parents('.form-group'); - helpText = element.find('#help_text'); - $rootScope.$digest(); }); - it('should contain auth_type select input', function(){ - expect(authType.length).toEqual(1); - }); + describe('when websso is enabled', function(){ - it('should show help text below auth_type', function(){ - expect(authType.next().get(0)).toEqual(helpText.get(0)); - }); + var element, + helpText, authType, + userInput, passwordInput; - it('should show help text', function(){ - expect(helpText).toBeVisible(); - }); + beforeEach(function(){ + element = $compile(websso_markup)($rootScope); + authType = element.find('#id_auth_type'); + userInput = element.find("#id_username").parents('.form-group'); + passwordInput = element.find("#id_password").parents('.form-group'); + helpText = element.find('#help_text'); + $rootScope.$digest(); + }); - it('should show username and password inputs', function(){ - expect(userInput).toBeVisible(); - expect(passwordInput).toBeVisible(); - }); + it('should contain auth_type select input', function(){ + expect(authType.length).toEqual(1); + }); + + it('should show help text below auth_type', function(){ + expect(authType.next().get(0)).toEqual(helpText.get(0)); + }); + + it('should show help text', function(){ + expect(helpText).toBeVisible(); + }); + + it('should show username and password inputs', function(){ + expect(userInput).toBeVisible(); + expect(passwordInput).toBeVisible(); + }); + + it('should hide username and password when user picks oidc', function(){ + authType.val('oidc'); + authType.change(); + $timeout.flush(); + expect(userInput).not.toBeVisible(); + expect(passwordInput).not.toBeVisible(); + }); - it('should hide username and password when user picks oidc', function(){ - authType.val('oidc'); - authType.change(); - $timeout.flush(); - expect(userInput).not.toBeVisible(); - expect(passwordInput).not.toBeVisible(); }); }); - -}); \ No newline at end of file +})(); \ No newline at end of file diff --git a/horizon/static/angular/metadata-display/metadata-display.spec.js b/horizon/static/angular/metadata-display/metadata-display.spec.js index 00d93963e0..79dcac3583 100644 --- a/horizon/static/angular/metadata-display/metadata-display.spec.js +++ b/horizon/static/angular/metadata-display/metadata-display.spec.js @@ -1,135 +1,136 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; -describe('hz.widget.metadata-display module', function() { - it('should have been defined', function () { - expect(angular.module('hz.widget.metadata-display')).toBeDefined(); - }); + describe('hz.widget.metadata-display module', function() { + it('should have been defined', function () { + expect(angular.module('hz.widget.metadata-display')).toBeDefined(); + }); - var namespaces = [ - { - "display_name": "Test Namespace A", - "description": "Test namespace description", - "properties": { - "test:A:1": { - "title": "Test A.1 - string", - "type": "string", - "default": "foo", - "enum": [ - "option-1", "option-2", "option-3" - ] - }, - "test:A:2": { - "title": "Test A.2 - integer", - "type": "integer", - "default": "1", - "minimum": 0, - "maximum": 10 - }, - "test:A:3": { - "title": "Test A.3 - number", - "type": "number", - "default": "1.1", - "minimum": 0, - "maximum": 10 - }, - "test:A:4": { - "title": "Test A.4 - boolean", - "type": "boolean", - "default": "True" - }, - "test:A:5": { - "title": "Test A.5 - boolean", - "type": "boolean", - "default": "false" - }, - "test:A:6": { - "title": "Test A.6 - array", - "type": "array", - "items": { + var namespaces = [ + { + "display_name": "Test Namespace A", + "description": "Test namespace description", + "properties": { + "test:A:1": { + "title": "Test A.1 - string", "type": "string", + "default": "foo", "enum": [ - "val-1", "val-2", "val-3" + "option-1", "option-2", "option-3" ] + }, + "test:A:2": { + "title": "Test A.2 - integer", + "type": "integer", + "default": "1", + "minimum": 0, + "maximum": 10 + }, + "test:A:3": { + "title": "Test A.3 - number", + "type": "number", + "default": "1.1", + "minimum": 0, + "maximum": 10 + }, + "test:A:4": { + "title": "Test A.4 - boolean", + "type": "boolean", + "default": "True" + }, + "test:A:5": { + "title": "Test A.5 - boolean", + "type": "boolean", + "default": "false" + }, + "test:A:6": { + "title": "Test A.6 - array", + "type": "array", + "items": { + "type": "string", + "enum": [ + "val-1", "val-2", "val-3" + ] + } } } + }, + { + "display_name": "Test Namespace B", + "description": "Test namespace description", + "objects": [ + { + "name": "Test Object A", + "description": "Test object description", + "properties": { + "test:B:A:1": { + "title": "Test B.A.1", + "description": "Test description" + }, + "test:B:A:2": {} + } + }, + { + "name": "Test Object B", + "description": "Test object description", + "properties": { + "test:B:B:1": {}, + "test:B:B:2": {} + } + } + ] } - }, - { - "display_name": "Test Namespace B", - "description": "Test namespace description", - "objects": [ - { - "name": "Test Object A", - "description": "Test object description", - "properties": { - "test:B:A:1": { - "title": "Test B.A.1", - "description": "Test description" - }, - "test:B:A:2": {} - } - }, - { - "name": "Test Object B", - "description": "Test object description", - "properties": { - "test:B:B:1": {}, - "test:B:B:2": {} - } - } - ] - } - ]; + ]; - var existing = { - 'test:A:1': 'option-2', - 'test:A:2': '5', - 'test:B:A:1': 'foo', - 'test:B:B:1': 'bar' - }; + var existing = { + 'test:A:1': 'option-2', + 'test:A:2': '5', + 'test:B:A:1': 'foo', + 'test:B:B:1': 'bar' + }; - describe('hzMetadataDisplay directive', function () { - var $scope, $element; + describe('hzMetadataDisplay directive', function () { + var $scope, $element; - beforeEach(module('templates')); - beforeEach(module('hz')); - beforeEach(module('hz.widgets')); - beforeEach(module('hz.widget.metadata-tree')); - beforeEach(module('hz.widget.metadata-display')); - beforeEach(inject(function ($injector) { - var $compile = $injector.get('$compile'); - $scope = $injector.get('$rootScope').$new(); + beforeEach(module('templates')); + beforeEach(module('hz')); + beforeEach(module('hz.widgets')); + beforeEach(module('hz.widget.metadata-tree')); + beforeEach(module('hz.widget.metadata-display')); + beforeEach(inject(function ($injector) { + var $compile = $injector.get('$compile'); + $scope = $injector.get('$rootScope').$new(); - $scope.available = namespaces; - $scope.existing = existing; + $scope.available = namespaces; + $scope.existing = existing; - var markup = - ''; + var markup = + ''; - $element = angular.element(markup); - $compile($element)($scope); - $scope.$digest(); - })); + $element = angular.element(markup); + $compile($element)($scope); + $scope.$digest(); + })); - it('should have 3 rows in selector list', function() { - expect($element.find('.selector .selector-item').length).toBe(3); + it('should have 3 rows in selector list', function() { + expect($element.find('.selector .selector-item').length).toBe(3); + }); + + it('should have 2 items in first group', function() { + expect($element.find('div[ng-repeat] div.auto-width').length).toBe(2); + }); + + it('should have 1 item in second group', function() { + $element.find('.selector .selector-item:nth-child(2)').trigger('click'); + expect($element.find('div[ng-repeat] div.auto-width').length).toBe(1); + }); + + it('should have proper description', function() { + expect($element.find('span[ng-bind="selected.description"]').text()).toBe(namespaces[0].description); + $element.find('.selector .selector-item:nth-child(2)').trigger('click'); + expect($element.find('span[ng-bind="selected.description"]').text()).toBe(namespaces[1].objects[0].description); + }); }); - it('should have 2 items in first group', function() { - expect($element.find('div[ng-repeat] div.auto-width').length).toBe(2); - }); - - it('should have 1 item in second group', function() { - $element.find('.selector .selector-item:nth-child(2)').trigger('click'); - expect($element.find('div[ng-repeat] div.auto-width').length).toBe(1); - }); - - it('should have proper description', function() { - expect($element.find('span[ng-bind="selected.description"]').text()).toBe(namespaces[0].description); - $element.find('.selector .selector-item:nth-child(2)').trigger('click'); - expect($element.find('span[ng-bind="selected.description"]').text()).toBe(namespaces[1].objects[0].description); - }); }); - -}); +})(); \ No newline at end of file diff --git a/horizon/static/angular/metadata-tree/metadata-tree.spec.js b/horizon/static/angular/metadata-tree/metadata-tree.spec.js index 23c051dc0a..ddd16754a8 100644 --- a/horizon/static/angular/metadata-tree/metadata-tree.spec.js +++ b/horizon/static/angular/metadata-tree/metadata-tree.spec.js @@ -1,189 +1,190 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; -describe('hz.widget.metadata-tree module', function() { - it('should have been defined', function () { - expect(angular.module('hz.widget.metadata-tree')).toBeDefined(); - }); + describe('hz.widget.metadata-tree module', function() { + it('should have been defined', function () { + expect(angular.module('hz.widget.metadata-tree')).toBeDefined(); + }); - var namespaces = [ - { - "display_name": "Test Namespace A", - "description": "Test namespace description", - "properties": { - "test:A:1": { - "title": "Test A.1 - string", - "type": "string", - "default": "foo", - "enum": [ - "option-1", "option-2", "option-3" - ] - }, - "test:A:2": { - "title": "Test A.2 - integer", - "type": "integer", - "default": "1", - "minimum": 0, - "maximum": 10 - }, - "test:A:3": { - "title": "Test A.3 - number", - "type": "number", - "default": "1.1", - "minimum": 0, - "maximum": 10 - }, - "test:A:4": { - "title": "Test A.4 - boolean", - "type": "boolean", - "default": "True" - }, - "test:A:5": { - "title": "Test A.5 - boolean", - "type": "boolean", - "default": "false" - }, - "test:A:6": { - "title": "Test A.6 - array", - "type": "array", - "items": { + var namespaces = [ + { + "display_name": "Test Namespace A", + "description": "Test namespace description", + "properties": { + "test:A:1": { + "title": "Test A.1 - string", "type": "string", + "default": "foo", "enum": [ - "val-1", "val-2", "val-3", "val-4" + "option-1", "option-2", "option-3" ] }, - "default": " val-2,val-3" - } - } - }, - { - "display_name": "Test Namespace B", - "description": "Test namespace description", - "objects": [ - { - "name": "Test Object A", - "description": "Test object description", - "properties": { - "test:B:A:1": { - "title": "Test B.A.1", - "description": "Test description" + "test:A:2": { + "title": "Test A.2 - integer", + "type": "integer", + "default": "1", + "minimum": 0, + "maximum": 10 + }, + "test:A:3": { + "title": "Test A.3 - number", + "type": "number", + "default": "1.1", + "minimum": 0, + "maximum": 10 + }, + "test:A:4": { + "title": "Test A.4 - boolean", + "type": "boolean", + "default": "True" + }, + "test:A:5": { + "title": "Test A.5 - boolean", + "type": "boolean", + "default": "false" + }, + "test:A:6": { + "title": "Test A.6 - array", + "type": "array", + "items": { + "type": "string", + "enum": [ + "val-1", "val-2", "val-3", "val-4" + ] }, - "test:B:A:2": {} - } - }, - { - "name": "Test Object B", - "description": "Test object description", - "properties": { - "test:B:B:1": {}, - "test:B:B:2": {} + "default": " val-2,val-3" } } - ] - } - ]; + }, + { + "display_name": "Test Namespace B", + "description": "Test namespace description", + "objects": [ + { + "name": "Test Object A", + "description": "Test object description", + "properties": { + "test:B:A:1": { + "title": "Test B.A.1", + "description": "Test description" + }, + "test:B:A:2": {} + } + }, + { + "name": "Test Object B", + "description": "Test object description", + "properties": { + "test:B:B:1": {}, + "test:B:B:2": {} + } + } + ] + } + ]; - describe('directives', function () { - var $scope, $element; + describe('directives', function () { + var $scope, $element; - beforeEach(module('templates')); - beforeEach(module('hz')); - beforeEach(module('hz.widgets')); - beforeEach(module('hz.widget.metadata-tree')); + beforeEach(module('templates')); + beforeEach(module('hz')); + beforeEach(module('hz.widgets')); + beforeEach(module('hz.widget.metadata-tree')); - describe('hzMetadataTree directive', function() { - beforeEach(inject(function ($injector) { - var $compile = $injector.get('$compile'); - $scope = $injector.get('$rootScope').$new(); + describe('hzMetadataTree directive', function() { + beforeEach(inject(function ($injector) { + var $compile = $injector.get('$compile'); + $scope = $injector.get('$rootScope').$new(); - $scope.available = namespaces; - $scope.existing = {'test:B:A:1':'foo'}; + $scope.available = namespaces; + $scope.existing = {'test:B:A:1':'foo'}; - var markup = - ''; + var markup = + ''; - $element = angular.element(markup); - $compile($element)($scope); - $scope.$digest(); - })); + $element = angular.element(markup); + $compile($element)($scope); + $scope.$digest(); + })); - it('should have 2 rows in available list', function() { - expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(2); + it('should have 2 rows in available list', function() { + expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(2); + }); + + it('should have 1 row in existing list', function() { + expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(1); + expect($element.find('ul.list-group:last li[ng-repeat]:first').scope().item.leaf.name).toBe('test:B:A:1'); + expect($element.find('ul.list-group:last li[ng-repeat]:first').scope().item.leaf.value).toBe('foo'); + }); + + it('should have 10 rows in available list when expanded items', function() { + $element.find('ul.list-group:first li[ng-repeat]:first').trigger('click'); + $element.find('ul.list-group:first li[ng-repeat]:last').trigger('click'); + expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(10); + }); + + it('should remove item from available and add it in existing list when added', function() { + $element.find('ul.list-group:first li[ng-repeat]:last').trigger('click'); + $element.find('ul.list-group:first li[ng-repeat]:last').trigger('click'); + expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(6); + $element.find('ul.list-group:first li[ng-repeat]:last .btn').trigger('click'); + expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(5); + expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(2); + expect($element.find('ul.list-group:last li[ng-repeat].active').scope().item.leaf.name).toBe('test:B:B:2'); + }); + + it('should add item to available and remove it from existing list when removed', function() { + $element.find('ul.list-group:last li[ng-repeat]:first .btn').trigger('click'); + expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(6); + expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(0); + expect($element.find('ul.list-group:first li[ng-repeat].active').scope().item.leaf.name).toBe('test:B:A:1'); + }); + + it('should add custom item to existing list', function() { + $element.find('ul.list-group:first li:first input').val('custom').trigger('input'); + $element.find('ul.list-group:first li:first .btn').trigger('click'); + expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(2); + expect($element.find('ul.list-group:last li[ng-repeat].active').scope().item.leaf.name).toBe('custom'); + }); }); - it('should have 1 row in existing list', function() { - expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(1); - expect($element.find('ul.list-group:last li[ng-repeat]:first').scope().item.leaf.name).toBe('test:B:A:1'); - expect($element.find('ul.list-group:last li[ng-repeat]:first').scope().item.leaf.value).toBe('foo'); - }); + describe('hzMetadataTreeItem directive', function() { + var $scope, $element, item; - it('should have 10 rows in available list when expanded items', function() { - $element.find('ul.list-group:first li[ng-repeat]:first').trigger('click'); - $element.find('ul.list-group:first li[ng-repeat]:last').trigger('click'); - expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(10); - }); + beforeEach(inject(function ($injector) { + var $compile = $injector.get('$compile'); + $scope = $injector.get('$rootScope').$new(); - it('should remove item from available and add it in existing list when added', function() { - $element.find('ul.list-group:first li[ng-repeat]:last').trigger('click'); - $element.find('ul.list-group:first li[ng-repeat]:last').trigger('click'); - expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(6); - $element.find('ul.list-group:first li[ng-repeat]:last .btn').trigger('click'); - expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(5); - expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(2); - expect($element.find('ul.list-group:last li[ng-repeat].active').scope().item.leaf.name).toBe('test:B:B:2'); - }); + item = new ($injector.get('metadataTreeService').Item)(); + $scope.item = item.fromProperty('test', namespaces[0].properties['test:A:6']); - it('should add item to available and remove it from existing list when removed', function() { - $element.find('ul.list-group:last li[ng-repeat]:first .btn').trigger('click'); - expect($element.find('ul.list-group:first li[ng-repeat]').length).toBe(6); - expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(0); - expect($element.find('ul.list-group:first li[ng-repeat].active').scope().item.leaf.name).toBe('test:B:A:1'); - }); + var markup = + ''; - it('should add custom item to existing list', function() { - $element.find('ul.list-group:first li:first input').val('custom').trigger('input'); - $element.find('ul.list-group:first li:first .btn').trigger('click'); - expect($element.find('ul.list-group:last li[ng-repeat]').length).toBe(2); - expect($element.find('ul.list-group:last li[ng-repeat].active').scope().item.leaf.name).toBe('custom'); - }); - }); + $element = angular.element(markup); + $compile($element)($scope); + $scope.$digest(); + })); - describe('hzMetadataTreeItem directive', function() { - var $scope, $element, item; + it('should have additional methods for array ', function () { + expect($element.isolateScope().opened).toBe(false); + expect($element.isolateScope().add).toBeDefined(); + expect($element.isolateScope().remove).toBeDefined(); + expect($element.isolateScope().open).toBeDefined(); + }); - beforeEach(inject(function ($injector) { - var $compile = $injector.get('$compile'); - $scope = $injector.get('$rootScope').$new(); + it('should add values to array ', function () { + $element.find('.options li:last').trigger('click'); + expect(item.leaf.getValue()).toBe(' val-2,val-3,val-4'); + $element.find('.options li:first').trigger('click'); + expect(item.leaf.getValue()).toBe(' val-1,val-2,val-3,val-4'); + }); - item = new ($injector.get('metadataTreeService').Item)(); - $scope.item = item.fromProperty('test', namespaces[0].properties['test:A:6']); - - var markup = - ''; - - $element = angular.element(markup); - $compile($element)($scope); - $scope.$digest(); - })); - - it('should have additional methods for array ', function () { - expect($element.isolateScope().opened).toBe(false); - expect($element.isolateScope().add).toBeDefined(); - expect($element.isolateScope().remove).toBeDefined(); - expect($element.isolateScope().open).toBeDefined(); - }); - - it('should add values to array ', function () { - $element.find('.options li:last').trigger('click'); - expect(item.leaf.getValue()).toBe(' val-2,val-3,val-4'); - $element.find('.options li:first').trigger('click'); - expect(item.leaf.getValue()).toBe(' val-1,val-2,val-3,val-4'); - }); - - it('should remove value from array ', function () { - $element.find('.values .label:first').trigger('click'); - expect(item.leaf.getValue()).toBe(' val-3'); + it('should remove value from array ', function () { + $element.find('.values .label:first').trigger('click'); + expect(item.leaf.getValue()).toBe(' val-3'); + }); }); }); }); -}); +})(); \ No newline at end of file diff --git a/horizon/static/angular/table/table.js b/horizon/static/angular/table/table.js index c3d7f6a650..b35d7f2638 100644 --- a/horizon/static/angular/table/table.js +++ b/horizon/static/angular/table/table.js @@ -1,4 +1,3 @@ -/* jshint globalstrict: true */ (function() { 'use strict'; diff --git a/horizon/static/angular/wizard/wizard.spec.js b/horizon/static/angular/wizard/wizard.spec.js index 9ba2f0927c..e55e281c50 100644 --- a/horizon/static/angular/wizard/wizard.spec.js +++ b/horizon/static/angular/wizard/wizard.spec.js @@ -1,163 +1,163 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; -describe('hz.widget.wizard module', function () { - it('should have been defined', function () { - expect(angular.module('hz.widget.wizard')).toBeDefined(); - }); -}); - -describe('wizard directive', function () { - var $compile, - $scope, - element; - - beforeEach(module('templates')); - beforeEach(module('hz')); - beforeEach(module('hz.widgets')); - beforeEach(module('hz.widget.wizard')); - beforeEach(inject(function ($injector) { - $scope = $injector.get('$rootScope').$new(); - $compile = $injector.get('$compile'); - element = $compile('')($scope); - })); - - it('should be compiled', function () { - var element = $compile('some text')($scope); - $scope.$digest(); - expect(element.html().trim()).not.toBe('some text'); + describe('hz.widget.wizard module', function () { + it('should have been defined', function () { + expect(angular.module('hz.widget.wizard')).toBeDefined(); + }); }); - it('should have empty title by default', function () { - $scope.workflow = {}; - $scope.$digest(); - expect(element[0].querySelector('.title').textContent).toBe(''); + describe('wizard directive', function () { + var $compile, + $scope, + element; + + beforeEach(module('templates')); + beforeEach(module('hz')); + beforeEach(module('hz.widgets')); + beforeEach(module('hz.widget.wizard')); + beforeEach(inject(function ($injector) { + $scope = $injector.get('$rootScope').$new(); + $compile = $injector.get('$compile'); + element = $compile('')($scope); + })); + + it('should be compiled', function () { + var element = $compile('some text')($scope); + $scope.$digest(); + expect(element.html().trim()).not.toBe('some text'); + }); + + it('should have empty title by default', function () { + $scope.workflow = {}; + $scope.$digest(); + expect(element[0].querySelector('.title').textContent).toBe(''); + }); + + it('should have title if it is specified by workflow', function () { + var titleText = 'Some title'; + $scope.workflow = {}; + $scope.workflow.title = titleText; + $scope.$digest(); + expect(element[0].querySelector('.title').textContent).toBe(titleText); + }); + + it('should have no steps if no steps defined', function () { + $scope.workflow = {}; + $scope.$digest(); + expect(element[0].querySelectorAll('.step').length).toBe(0); + }); + + it('should have 3 steps if 3 steps defined', function () { + $scope.workflow = { + steps: [ {}, {}, {} ] + }; + $scope.$digest(); + expect(element[0].querySelectorAll('.step').length).toBe(3); + }); + + it('should have no nav items if no steps defined', function () { + $scope.workflow = {}; + $scope.$digest(); + expect(element[0].querySelectorAll('.nav-item').length).toBe(0); + }); + + it('should have 3 nav items if 3 steps defined', function () { + $scope.workflow = { + steps: [ {}, {}, {} ] + }; + $scope.$digest(); + expect(element[0].querySelectorAll('.nav-item').length).toBe(3); + }); + + it('should navigate correctly', function () { + $scope.workflow = { + steps: [ {}, {}, {} ] + }; + + $scope.$digest(); + expect($scope.currentIndex).toBe(0); + expect($(element).find('.step').eq(0).hasClass('ng-hide')).toBe(false); + expect($(element).find('.step').eq(1).hasClass('ng-hide')).toBe(true); + expect($(element).find('.step').eq(2).hasClass('ng-hide')).toBe(true); + expect($(element).find('.nav-item').eq(0).hasClass('current')).toBe(true); + expect($(element).find('.nav-item').eq(1).hasClass('current')).toBe(false); + expect($(element).find('.nav-item').eq(2).hasClass('current')).toBe(false); + + $scope.switchTo(1); + $scope.$digest(); + expect($scope.currentIndex).toBe(1); + expect($(element).find('.step').eq(0).hasClass('ng-hide')).toBe(true); + expect($(element).find('.step').eq(1).hasClass('ng-hide')).toBe(false); + expect($(element).find('.step').eq(2).hasClass('ng-hide')).toBe(true); + expect($(element).find('.nav-item').eq(0).hasClass('current')).toBe(false); + expect($(element).find('.nav-item').eq(1).hasClass('current')).toBe(true); + expect($(element).find('.nav-item').eq(2).hasClass('current')).toBe(false); + + $scope.switchTo(2); + $scope.$digest(); + expect($scope.currentIndex).toBe(2); + expect($(element).find('.step').eq(0).hasClass('ng-hide')).toBe(true); + expect($(element).find('.step').eq(1).hasClass('ng-hide')).toBe(true); + expect($(element).find('.step').eq(2).hasClass('ng-hide')).toBe(false); + expect($(element).find('.nav-item').eq(0).hasClass('current')).toBe(false); + expect($(element).find('.nav-item').eq(1).hasClass('current')).toBe(false); + expect($(element).find('.nav-item').eq(2).hasClass('current')).toBe(true); + }); + + it('should not show back button in step 1/3', function () { + $scope.workflow = { + steps: [{}, {}, {}] + }; + $scope.$digest(); + expect($(element).find('button.back').hasClass('ng-hide')).toBe(true); + expect($(element).find('button.next').hasClass('ng-hide')).toBe(false); + }); + + it('should show both back and next button in step 2/3', function () { + $scope.workflow = { + steps: [{}, {}, {}] + }; + $scope.$digest(); + $scope.switchTo(1); + $scope.$digest(); + expect($(element).find('button.back').hasClass('ng-hide')).toBe(false); + expect($(element).find('button.next').hasClass('ng-hide')).toBe(false); + }); + + it('should not show next button in step 3/3', function () { + $scope.workflow = { + steps: [{}, {}, {}] + }; + $scope.$digest(); + $scope.switchTo(2); + $scope.$digest(); + expect($(element).find('button.back').hasClass('ng-hide')).toBe(false); + expect($(element).find('button.next').hasClass('ng-hide')).toBe(true); + }); + + it('should have finish button disabled if wizardForm is invalid', function () { + $scope.wizardForm = { }; + $scope.$digest(); + $scope.wizardForm.$invalid = true; + $scope.$digest(); + expect(element[0].querySelector('button.finish').hasAttribute('disabled')).toBe(true); + }); + + it('should have finish button enabled if wizardForm is valid', function () { + $scope.wizardForm = { }; + $scope.$digest(); + $scope.wizardForm.$invalid = false; + $scope.$digest(); + expect(element[0].querySelector('button.finish').hasAttribute('disabled')).toBe(false); + }); + + it('should show error message after calling method showError', function () { + var errorMessage = 'some error message'; + $scope.$digest(); + $scope.showError(errorMessage); + $scope.$digest(); + expect(element[0].querySelector('.error-message').textContent).toBe(errorMessage); + }); }); - - it('should have title if it is specified by workflow', function () { - var titleText = 'Some title'; - $scope.workflow = {}; - $scope.workflow.title = titleText; - $scope.$digest(); - expect(element[0].querySelector('.title').textContent).toBe(titleText); - }); - - it('should have no steps if no steps defined', function () { - $scope.workflow = {}; - $scope.$digest(); - expect(element[0].querySelectorAll('.step').length).toBe(0); - }); - - it('should have 3 steps if 3 steps defined', function () { - $scope.workflow = { - steps: [ {}, {}, {} ] - }; - $scope.$digest(); - expect(element[0].querySelectorAll('.step').length).toBe(3); - }); - - it('should have no nav items if no steps defined', function () { - $scope.workflow = {}; - $scope.$digest(); - expect(element[0].querySelectorAll('.nav-item').length).toBe(0); - }); - - it('should have 3 nav items if 3 steps defined', function () { - $scope.workflow = { - steps: [ {}, {}, {} ] - }; - $scope.$digest(); - expect(element[0].querySelectorAll('.nav-item').length).toBe(3); - }); - - it('should navigate correctly', function () { - $scope.workflow = { - steps: [ {}, {}, {} ] - }; - - $scope.$digest(); - expect($scope.currentIndex).toBe(0); - expect($(element).find('.step').eq(0).hasClass('ng-hide')).toBe(false); - expect($(element).find('.step').eq(1).hasClass('ng-hide')).toBe(true); - expect($(element).find('.step').eq(2).hasClass('ng-hide')).toBe(true); - expect($(element).find('.nav-item').eq(0).hasClass('current')).toBe(true); - expect($(element).find('.nav-item').eq(1).hasClass('current')).toBe(false); - expect($(element).find('.nav-item').eq(2).hasClass('current')).toBe(false); - - $scope.switchTo(1); - $scope.$digest(); - expect($scope.currentIndex).toBe(1); - expect($(element).find('.step').eq(0).hasClass('ng-hide')).toBe(true); - expect($(element).find('.step').eq(1).hasClass('ng-hide')).toBe(false); - expect($(element).find('.step').eq(2).hasClass('ng-hide')).toBe(true); - expect($(element).find('.nav-item').eq(0).hasClass('current')).toBe(false); - expect($(element).find('.nav-item').eq(1).hasClass('current')).toBe(true); - expect($(element).find('.nav-item').eq(2).hasClass('current')).toBe(false); - - $scope.switchTo(2); - $scope.$digest(); - expect($scope.currentIndex).toBe(2); - expect($(element).find('.step').eq(0).hasClass('ng-hide')).toBe(true); - expect($(element).find('.step').eq(1).hasClass('ng-hide')).toBe(true); - expect($(element).find('.step').eq(2).hasClass('ng-hide')).toBe(false); - expect($(element).find('.nav-item').eq(0).hasClass('current')).toBe(false); - expect($(element).find('.nav-item').eq(1).hasClass('current')).toBe(false); - expect($(element).find('.nav-item').eq(2).hasClass('current')).toBe(true); - }); - - it('should not show back button in step 1/3', function () { - $scope.workflow = { - steps: [{}, {}, {}] - }; - $scope.$digest(); - expect($(element).find('button.back').hasClass('ng-hide')).toBe(true); - expect($(element).find('button.next').hasClass('ng-hide')).toBe(false); - }); - - it('should show both back and next button in step 2/3', function () { - $scope.workflow = { - steps: [{}, {}, {}] - }; - $scope.$digest(); - $scope.switchTo(1); - $scope.$digest(); - expect($(element).find('button.back').hasClass('ng-hide')).toBe(false); - expect($(element).find('button.next').hasClass('ng-hide')).toBe(false); - }); - - it('should not show next button in step 3/3', function () { - $scope.workflow = { - steps: [{}, {}, {}] - }; - $scope.$digest(); - $scope.switchTo(2); - $scope.$digest(); - expect($(element).find('button.back').hasClass('ng-hide')).toBe(false); - expect($(element).find('button.next').hasClass('ng-hide')).toBe(true); - }); - - it('should have finish button disabled if wizardForm is invalid', function () { - $scope.wizardForm = { }; - $scope.$digest(); - $scope.wizardForm.$invalid = true; - $scope.$digest(); - expect(element[0].querySelector('button.finish').hasAttribute('disabled')).toBe(true); - }); - - it('should have finish button enabled if wizardForm is valid', function () { - $scope.wizardForm = { }; - $scope.$digest(); - $scope.wizardForm.$invalid = false; - $scope.$digest(); - expect(element[0].querySelector('button.finish').hasAttribute('disabled')).toBe(false); - }); - - it('should show error message after calling method showError', function () { - var errorMessage = 'some error message'; - $scope.$digest(); - $scope.showError(errorMessage); - $scope.$digest(); - expect(element[0].querySelector('.error-message').textContent).toBe(errorMessage); - }); - -}); +})(); diff --git a/openstack_dashboard/static/dashboard/launch-instance/flavor/flavor.spec.js b/openstack_dashboard/static/dashboard/launch-instance/flavor/flavor.spec.js index aaf98a4863..24b02d5725 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/flavor/flavor.spec.js +++ b/openstack_dashboard/static/dashboard/launch-instance/flavor/flavor.spec.js @@ -1,4 +1,3 @@ -/* jshint globalstrict: true */ /* * (c) Copyright 2015 Hewlett-Packard Development Company, L.P. * diff --git a/openstack_dashboard/static/dashboard/launch-instance/launch-instance.model.spec.js b/openstack_dashboard/static/dashboard/launch-instance/launch-instance.model.spec.js index 2c4b787fc8..23ad2fab56 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/launch-instance.model.spec.js +++ b/openstack_dashboard/static/dashboard/launch-instance/launch-instance.model.spec.js @@ -1,2 +1,4 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; + +})(); diff --git a/openstack_dashboard/static/dashboard/launch-instance/launch-instance.spec.js b/openstack_dashboard/static/dashboard/launch-instance/launch-instance.spec.js index 2c4b787fc8..23ad2fab56 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/launch-instance.spec.js +++ b/openstack_dashboard/static/dashboard/launch-instance/launch-instance.spec.js @@ -1,2 +1,4 @@ -/* jshint globalstrict: true */ -'use strict'; +(function(){ + 'use strict'; + +})(); diff --git a/openstack_dashboard/static/dashboard/launch-instance/source/source.spec.js b/openstack_dashboard/static/dashboard/launch-instance/source/source.spec.js index 1aa1d9697c..1e61adac86 100644 --- a/openstack_dashboard/static/dashboard/launch-instance/source/source.spec.js +++ b/openstack_dashboard/static/dashboard/launch-instance/source/source.spec.js @@ -1,4 +1,3 @@ -/* jshint globalstrict: true */ /* * (c) Copyright 2015 Hewlett-Packard Development Company, L.P. *