From 9dcdc2ff62a831d185a3ddbc6597a68d22efcafb Mon Sep 17 00:00:00 2001 From: Peter Piela Date: Tue, 4 Oct 2016 18:32:49 -0400 Subject: [PATCH] Fix Jasmine unit tests Fixed unit tests in the base-node and node-details areas. The tests had not kept up with development updates. Change-Id: I88b4aa00bb811a02d51c5818e70ce5ceb0f8c896 --- .../admin/ironic/base-node/base-node.spec.js | 6 ++--- .../node-details.controller.spec.js | 26 ++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.spec.js b/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.spec.js index 2cd47cdf..f5f1da15 100644 --- a/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.spec.js +++ b/ironic_ui/static/dashboard/admin/ironic/base-node/base-node.spec.js @@ -52,9 +52,9 @@ expect(property.propertySet).toBe(propertySet); expect(property.getSelectOptions()).toBe(null); expect(property.required).toBe(false); - expect(property.defaultValue).toBe(null); - expect(property.inputValue).toBe(null); - expect(property.getInputValue()).toBe(null); + expect(property.defaultValue).toBe(undefined); + expect(property.inputValue).toBe(undefined); + expect(property.getInputValue()).toBe(undefined); expect(property.isActive()).toBe(true); }); diff --git a/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.spec.js b/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.spec.js index 091197b1..0b5c8d36 100755 --- a/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.spec.js +++ b/ironic_ui/static/dashboard/admin/ironic/node-details/node-details.controller.spec.js @@ -28,7 +28,8 @@ } function createPort(nodeUuid, index, extra) { - var port = {uuid: portUuid(nodeUuid, index)}; + var uuid = portUuid(nodeUuid, index); + var port = {uuid: uuid, id: uuid}; if (angular.isDefined(extra)) { port.extra = extra; } @@ -36,7 +37,7 @@ } function createNode(name, uuid) { - return {name: name, uuid: uuid}; + return {name: name, uuid: uuid, id: uuid}; } var ironicAPI = { @@ -61,6 +62,16 @@ ironicAPI); })); + beforeEach(module(function($provide) { + $provide.value('horizon.framework.widgets.toast.service', + {}); + })); + + beforeEach(module(function($provide) { + $provide.value('horizon.dashboard.admin.ironic.edit-node.service', + {}); + })); + beforeEach(module(function($provide) { $provide.value('horizon.dashboard.admin.ironic.maintenance.service', {}); @@ -75,7 +86,8 @@ ctrl = controller( 'horizon.dashboard.admin.ironic.NodeDetailsController', - {$location: $location, + {$scope: scope, + $location: $location, 'horizon.dashboard.admin.ironic.actions': {}, 'horizon.dashboard.admin.basePath': '/static'}); @@ -97,14 +109,14 @@ }); it('should have ports', function () { - expect(ctrl.ports).toBeDefined(); - expect(ctrl.ports.length).toEqual(numPorts); + expect(ctrl.portsSrc).toBeDefined(); + expect(ctrl.portsSrc.length).toEqual(numPorts); var ports = []; - for (var i = 0; i < ctrl.ports.length; i++) { + for (var i = 0; i < numPorts; i++) { ports.push(createPort(ctrl.node.uuid, i)); } - expect(ctrl.ports).toEqual(ports); + expect(ctrl.portsSrc).toEqual(ports); }); it('should have a uuid regular expression pattern', function () {