[Mobile] Restore browse controller from master

This commit is contained in:
Victor Woeltjen 2015-09-17 17:42:23 -07:00
parent 2090b1a958
commit 19500c2704
2 changed files with 10 additions and 35 deletions

View File

@ -55,7 +55,7 @@ define(
unlisten = $scope.$on('$locationChangeSuccess', function () {
// Checks path to make sure /browse/ is at front
// if so, change $route.current
// if so, change $route.current
if ($location.path().indexOf("/browse/") === 0) {
$route.current = priorRoute;
}
@ -65,6 +65,7 @@ define(
// path to new, addressed, path based on
// domainObject
$location.path(urlService.urlForLocation("browse", domainObject));
}
// Callback for updating the in-scope reference to the object
@ -152,6 +153,7 @@ define(
$scope.$on("$destroy", function () {
navigationService.removeListener(setNavigation);
});
}
return BrowseController;

View File

@ -39,9 +39,6 @@ define(
mockUrlService,
mockDomainObject,
mockNextObject,
mockParentContext,
mockParent,
mockGrandparent,
controller;
function mockPromise(value) {
@ -55,7 +52,7 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
[ "$on", "$watch", "treeSlide", "backArrow" ]
[ "$on", "$watch" ]
);
mockRoute = { current: { params: {} } };
mockLocation = jasmine.createSpyObj(
@ -92,17 +89,6 @@ define(
[ "getId", "getCapability", "getModel", "useCapability" ]
);
mockParentContext = jasmine.createSpyObj('context', ['getParent']);
mockParent = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
);
mockGrandparent = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability", "getModel", "useCapability" ]
);
mockObjectService.getObjects.andReturn(mockPromise({
ROOT: mockRootObject
}));
@ -160,25 +146,12 @@ define(
expect(mockScope.navigatedObject).toEqual(mockDomainObject);
});
// Mocks the tree slide call that
// lets the html code know if the
// tree menu is open.
it("calls the treeSlide function", function () {
expect(mockScope.$on).toHaveBeenCalledWith(
"select-obj",
jasmine.any(Function)
);
mockScope.$on.calls[1].args[1]();
});
it("releases its navigation listener when its scope is destroyed", function () {
expect(mockScope.$on).toHaveBeenCalledWith(
"$destroy",
jasmine.any(Function)
);
mockScope.$on.calls[0].args[1]();
mockScope.$on.mostRecentCall.args[1]();
// Should remove the listener it added earlier
expect(mockNavigationService.removeListener).toHaveBeenCalledWith(
mockNavigationService.addListener.mostRecentCall.args[0]
@ -249,16 +222,16 @@ define(
mockNavigationService.addListener.mostRecentCall.args[0](
mockNextObject
);
// Allows the path index to be checked
// prior to setting $route.current
// prior to setting $route.current
mockLocation.path.andReturn("/browse/");
// Exercise the Angular workaround
mockScope.$on.mostRecentCall.args[1]();
expect(mockUnlisten).toHaveBeenCalled();
// 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
expect(mockLocation.path).toHaveBeenCalledWith(
mockUrlService.urlForLocation(mockMode, mockNextObject)