[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:
Pete Richards 2015-08-04 13:13:00 -07:00
parent 197ec0eb2c
commit 3fb4296d23

View File

@ -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;