[Windowing] Unit Test

Added mockContext to
UrlServiceSpec unit test
in order to reach the
domainObject's context
capability. WTD 16.
This commit is contained in:
Shivam Dave 2015-06-24 12:31:40 -07:00
parent 8926d4b2fb
commit 13eef59e4f

View File

@ -33,10 +33,7 @@ define(
var mockUrl, var mockUrl,
mockUrlFor, mockUrlFor,
urlService, urlService,
mockLocation, mockLocation;
mockDomainObject,
mockMode,
mockObject;
beforeEach(function () { beforeEach(function () {
mockLocation = jasmine.createSpyObj( mockLocation = jasmine.createSpyObj(
@ -52,16 +49,25 @@ define(
"domainObject", "domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ] [ "getId", "getCapability", "getModel", "useCapability" ]
), ),
mockContext = jasmine.createSpyObj('context', ['getPath']),
testViews = [ testViews = [
{ key: 'abc' }, { key: 'abc' },
{ key: 'def', someKey: 'some value' }, { key: 'def', someKey: 'some value' },
{ key: 'xyz' } { key: 'xyz' }
]; ];
mockContext.getPath.andReturn(
[mockDomainObject]
);
mockDomainObject.useCapability.andCallFake(function (c) { mockDomainObject.useCapability.andCallFake(function (c) {
return (c === 'view') && testViews; return (c === 'view') && testViews;
}); });
mockDomainObject.getId.andReturn(true);
mockDomainObject.getCapability.andCallFake(function (c) {
return c === 'context' && mockContext;
});
mockLocation.search.andReturn({ view: 'def' }); mockLocation.search.andReturn({ view: 'def' });
urlService.urlFor("browse", mockDomainObject); urlService.urlFor("browse", mockDomainObject);
}); });