mirror of
https://github.com/nasa/openmct.git
synced 2024-12-25 15:51:04 +00:00
[Entanglement] Link service returns object in new context
The link service return the object in the new context.
This commit is contained in:
parent
4c56e4ffdc
commit
4a755e259f
@ -66,6 +66,17 @@ define(
|
|||||||
}
|
}
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return parentObject.getCapability('persistence').persist();
|
return parentObject.getCapability('persistence').persist();
|
||||||
|
}).then(function getObjectWithNewContext() {
|
||||||
|
return parentObject
|
||||||
|
.useCapability('composition')
|
||||||
|
.then(function (children) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < children.length; i += 1) {
|
||||||
|
if (children[i].getId() === object.getId()) {
|
||||||
|
return children[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'../../src/services/LinkService',
|
'../../src/services/LinkService',
|
||||||
'../DomainObjectFactory'
|
'../DomainObjectFactory',
|
||||||
|
'../ControlledPromise'
|
||||||
],
|
],
|
||||||
function (LinkService, domainObjectFactory) {
|
function (LinkService, domainObjectFactory) {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -177,6 +178,11 @@ define(
|
|||||||
|
|
||||||
expect(persistenceCapability.persist).toHaveBeenCalled();
|
expect(persistenceCapability.persist).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns object representing new link", function () {
|
||||||
|
linkService.perform(object, parentObject);
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,10 @@
|
|||||||
/*global define,jasmine */
|
/*global define,jasmine */
|
||||||
|
|
||||||
define(
|
define(
|
||||||
function () {
|
[
|
||||||
|
'../ControlledPromise'
|
||||||
|
],
|
||||||
|
function (ControlledPromise) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,26 +70,12 @@ define(
|
|||||||
callExtensions,
|
callExtensions,
|
||||||
spy;
|
spy;
|
||||||
|
|
||||||
performPromise = jasmine.createSpyObj(
|
performPromise = new ControlledPromise();
|
||||||
'performPromise',
|
|
||||||
['then']
|
|
||||||
);
|
|
||||||
|
|
||||||
callExtensions = {
|
this.perform.mostRecentCall.promise = performPromise;
|
||||||
promise: performPromise,
|
this.perform.calls[this.perform.calls.length - 1].promise =
|
||||||
resolve: function (resolveWith) {
|
performPromise;
|
||||||
performPromise.then.calls.forEach(function (call) {
|
|
||||||
call.args[0](resolveWith);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
spy = this.perform;
|
|
||||||
|
|
||||||
Object.keys(callExtensions).forEach(function (key) {
|
|
||||||
spy.mostRecentCall[key] = callExtensions[key];
|
|
||||||
spy.calls[spy.calls.length - 1][key] = callExtensions[key];
|
|
||||||
});
|
|
||||||
|
|
||||||
return performPromise;
|
return performPromise;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user