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
This commit is contained in:
Miles Gould 2017-03-24 12:10:56 +00:00
parent a887caa844
commit a4c89967d8

View File

@ -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() {