diff --git a/platform/commonUI/browse/src/BrowseController.js b/platform/commonUI/browse/src/BrowseController.js index 9f6ca3e077..b10e0a598a 100644 --- a/platform/commonUI/browse/src/BrowseController.js +++ b/platform/commonUI/browse/src/BrowseController.js @@ -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; diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index be215bebe4..ce9296c239 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -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)