[Windowing] Unit Test
Added Unit test adjustments for the change in urlService (addition of a separate function for getting the url for a location, used by browse controller. WTD 23.
This commit is contained in:
@@ -61,7 +61,7 @@ define(
|
|||||||
);
|
);
|
||||||
mockUrlService = jasmine.createSpyObj(
|
mockUrlService = jasmine.createSpyObj(
|
||||||
"urlService",
|
"urlService",
|
||||||
["urlFor"]
|
["urlForLocation"]
|
||||||
);
|
);
|
||||||
mockObjectService = jasmine.createSpyObj(
|
mockObjectService = jasmine.createSpyObj(
|
||||||
"objectService",
|
"objectService",
|
||||||
@@ -225,7 +225,7 @@ define(
|
|||||||
// location.path to be called with the urlService's
|
// location.path to be called with the urlService's
|
||||||
// urlFor function with the next domainObject and mode
|
// urlFor function with the next domainObject and mode
|
||||||
expect(mockLocation.path).toHaveBeenCalledWith(
|
expect(mockLocation.path).toHaveBeenCalledWith(
|
||||||
mockUrlService.urlFor(mockMode, mockNextObject)
|
mockUrlService.urlForLocation(mockMode, mockNextObject)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Exercise the Angular workaround
|
// Exercise the Angular workaround
|
||||||
|
|||||||
@@ -31,7 +31,11 @@ define(
|
|||||||
|
|
||||||
describe("The url service", function () {
|
describe("The url service", function () {
|
||||||
var urlService,
|
var urlService,
|
||||||
mockLocation;
|
mockLocation,
|
||||||
|
mockDomainObject,
|
||||||
|
mockContext,
|
||||||
|
mockMode,
|
||||||
|
testViews;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
// Creates a mockLocation, used to
|
// Creates a mockLocation, used to
|
||||||
@@ -41,23 +45,19 @@ define(
|
|||||||
[ "path", "search" ]
|
[ "path", "search" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
urlService = new UrlService(mockLocation);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("get url for a domainObject and mode", function () {
|
|
||||||
// The mockDomainObject is initialized as a
|
// The mockDomainObject is initialized as a
|
||||||
// spy object to ultimately be passed into the
|
// spy object to ultimately be passed into the
|
||||||
// urlService urlFor function
|
// urlService urlFor function
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability", "getModel", "useCapability" ]
|
[ "getId", "getCapability", "getModel", "useCapability" ]
|
||||||
),
|
);
|
||||||
mockContext = jasmine.createSpyObj('context', ['getPath']),
|
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' }
|
||||||
],
|
];
|
||||||
mockMode = "browse";
|
mockMode = "browse";
|
||||||
|
|
||||||
// The mockContext is set a path
|
// The mockContext is set a path
|
||||||
@@ -81,7 +81,16 @@ define(
|
|||||||
// Uses the mockLocation to get the current
|
// Uses the mockLocation to get the current
|
||||||
// "mock" website's view
|
// "mock" website's view
|
||||||
mockLocation.search.andReturn({ view: 'def' });
|
mockLocation.search.andReturn({ view: 'def' });
|
||||||
urlService.urlFor(mockMode, mockDomainObject);
|
|
||||||
|
urlService = new UrlService(mockLocation);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("get url for a location using domainObject and mode", function () {
|
||||||
|
urlService.urlForLocation(mockMode, mockDomainObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("get url for a new tab using domainObject and mode", function () {
|
||||||
|
urlService.urlForNewTab(mockMode, mockDomainObject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ define(
|
|||||||
|
|
||||||
// Mocks the urlService used to make the new tab's url from a
|
// Mocks the urlService used to make the new tab's url from a
|
||||||
// domainObject and mode
|
// domainObject and mode
|
||||||
mockUrlService = jasmine.createSpyObj("urlService", ["urlFor"]);
|
mockUrlService = jasmine.createSpyObj("urlService", ["urlForNewTab"]);
|
||||||
|
|
||||||
// Action done using the current context or mockContextCurrent
|
// Action done using the current context or mockContextCurrent
|
||||||
actionCurrent = new NewTabAction(mockUrlService, mockWindow,
|
actionCurrent = new NewTabAction(mockUrlService, mockWindow,
|
||||||
|
|||||||
Reference in New Issue
Block a user