[urlService] CleanUp/Refactor

Adjusted BrowseController's useRoute
to use the urlService instead. Also
adds urlService as a depency through
bundle. Unit test also adjusted to
account for a mockUrlService and
a different value being passed into
mockLocation.path(). WTD 16.
This commit is contained in:
Shivam Dave
2015-06-24 14:06:09 -07:00
parent c827c40c03
commit bd9010e2bc
3 changed files with 25 additions and 16 deletions

View File

@@ -36,6 +36,7 @@ define(
mockObjectService,
mockNavigationService,
mockRootObject,
mockUrlService,
mockDomainObject,
mockNextObject,
controller;
@@ -58,6 +59,10 @@ define(
"$location",
[ "path" ]
);
mockUrlService = jasmine.createSpyObj(
"urlService",
["urlFor"]
);
mockObjectService = jasmine.createSpyObj(
"objectService",
[ "getObjects" ]
@@ -102,7 +107,8 @@ define(
mockRoute,
mockLocation,
mockObjectService,
mockNavigationService
mockNavigationService,
mockUrlService
);
});
@@ -112,7 +118,8 @@ define(
mockRoute,
mockLocation,
mockObjectService,
mockNavigationService
mockNavigationService,
mockUrlService
);
expect(mockNavigationService.setNavigation)
.toHaveBeenCalledWith(mockDomainObject);
@@ -125,7 +132,8 @@ define(
mockRoute,
mockLocation,
mockObjectService,
mockNavigationService
mockNavigationService,
mockUrlService
);
expect(mockScope.navigatedObject).toBe(mockDomainObject);
});
@@ -200,7 +208,8 @@ define(
it("updates the displayed route to reflect current navigation", function () {
var mockContext = jasmine.createSpyObj('context', ['getPath']),
mockUnlisten = jasmine.createSpy('unlisten');
mockUnlisten = jasmine.createSpy('unlisten'),
mockMode = "browse";
mockContext.getPath.andReturn(
[mockRootObject, mockDomainObject, mockNextObject]
@@ -213,7 +222,11 @@ define(
mockNavigationService.addListener.mostRecentCall.args[0](
mockNextObject
);
expect(mockLocation.path).toHaveBeenCalledWith("/browse/mine/next");
// location.path to be called with the urlService's
// urlFor function with the next domainObject and mode
expect(mockLocation.path).toHaveBeenCalledWith(
mockUrlService.urlFor(mockMode, mockNextObject)
);
// Exercise the Angular workaround
mockScope.$on.mostRecentCall.args[1]();