mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
[Testing] MockLinkService returns linked object
MockLinkService.perform returns a promise for the linked domainObject. When resolving the promise and not specifying an object to resolve it with, it will resolve it with the domainObject that was originally passed to it.
This commit is contained in:
parent
197ec0eb2c
commit
3fb4296d23
@ -50,7 +50,7 @@ define(
|
||||
* var whenLinked = jasmine.createSpy('whenLinked');
|
||||
* linkService.perform(object, parentObject).then(whenLinked);
|
||||
* expect(whenLinked).not.toHaveBeenCalled();
|
||||
* linkService.perform.mostRecentCall.resolve('someArg');
|
||||
* linkService.perform.mostRecentCall.promise.resolve('someArg');
|
||||
* expect(whenLinked).toHaveBeenCalledWith('someArg');
|
||||
* ```
|
||||
*/
|
||||
@ -65,19 +65,19 @@ define(
|
||||
]
|
||||
);
|
||||
|
||||
mockLinkService.perform.andCallFake(function () {
|
||||
var performPromise,
|
||||
callExtensions,
|
||||
spy;
|
||||
|
||||
performPromise = new ControlledPromise();
|
||||
mockLinkService.perform.andCallFake(function (object, newParent) {
|
||||
var performPromise = new ControlledPromise();
|
||||
|
||||
this.perform.mostRecentCall.promise = performPromise;
|
||||
this.perform.calls[this.perform.calls.length - 1].promise =
|
||||
performPromise;
|
||||
|
||||
|
||||
return performPromise;
|
||||
return performPromise.then(function (overrideObject) {
|
||||
if (overrideObject) {
|
||||
return overrideObject;
|
||||
}
|
||||
return object;
|
||||
});
|
||||
});
|
||||
|
||||
return mockLinkService;
|
||||
|
Loading…
Reference in New Issue
Block a user