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

View File

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