From a4c89967d8cf0e34ee9d41a860ce512d772347af Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Fri, 24 Mar 2017 12:10:56 +0000 Subject: [PATCH] Fix mocks that were breaking Jasmine tests - The getNode mock was wrapping the node in an outer object. This does not match the behaviour of the real function, and was breaking JavaScript unit tests. - The getPortsWithNode mock was wrapping the list of nodes in *two* outer objects, and not populating the created port objects with all the expected fields. This commit changes it to match the expected behaviour (and the real behaviour of the method it's mocking). Change-Id: I1abaaa932e4f80780d3b8d61c6ca12557430ab26 --- .../ironic/node-details/node-details.controller.spec.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 635d9714..8fe5095f 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 @@ -38,6 +38,8 @@ function createPort(nodeUuid, index, extra) { var port = {uuid: portUuid(nodeUuid, index), address: portMacAddr(index)}; + port.id = port.uuid; + port.name = port.address; if (angular.isDefined(extra)) { port.extra = extra; } @@ -53,7 +55,7 @@ var ironicAPI = { getNode: function (uuid) { var node = createNode(nodeName, uuid); - return $q.when({data: node}); + return $q.when(node); }, getPortsWithNode: function (uuid) { @@ -61,7 +63,7 @@ for (var i = 0; i < numPorts; i++) { ports.push(createPort(uuid, i)); } - return $q.when({data: {items: ports}}); + return $q.when(ports); }, validateNode: function() {