From 2d1aa65d63f399c9aec0ce186a832f7c30d8a093 Mon Sep 17 00:00:00 2001 From: Shivam Dave Date: Thu, 30 Jul 2015 12:50:39 -0700 Subject: [PATCH] [Mobile] Test BrowseController test adjusted to repeat less code. --- .../browse/test/BrowseControllerSpec.js | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index a4be906b1d..722b7b4132 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -39,6 +39,9 @@ define( mockUrlService, mockDomainObject, mockNextObject, + mockParentContext, + mockParent, + mockGrandparent, controller; function mockPromise(value) { @@ -88,6 +91,17 @@ define( "nextObject", [ "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 @@ -246,25 +260,7 @@ define( }); it("checks if the user is current navigated to the root", function () { - var mockContext = jasmine.createSpyObj('context', ['getParent']), - mockParentContext = jasmine.createSpyObj('context', ['getParent']), - mockParent = jasmine.createSpyObj( - "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] - ), - mockGrandparent = jasmine.createSpyObj( - "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] - ); - mockNavigationService = jasmine.createSpyObj( - "navigationService", - [ - "getNavigation", - "setNavigation", - "addListener", - "removeListener" - ] - ); + var mockContext = jasmine.createSpyObj('context', ['getParent']); mockRoute.current.params.ids = "ROOT/mine"; mockParent.getId.andReturn("ROOT"); @@ -308,25 +304,7 @@ define( // lets the html code know the back // arrow navigation needs to be done it("calls the backArrow function", function () { - var mockContext = jasmine.createSpyObj('context', ['getParent']), - mockParentContext = jasmine.createSpyObj('context', ['getParent']), - mockParent = jasmine.createSpyObj( - "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] - ), - mockGrandparent = jasmine.createSpyObj( - "domainObject", - [ "getId", "getCapability", "getModel", "useCapability" ] - ); - mockNavigationService = jasmine.createSpyObj( - "navigationService", - [ - "getNavigation", - "setNavigation", - "addListener", - "removeListener" - ] - ); + var mockContext = jasmine.createSpyObj('context', ['getParent']); mockRoute.current.params.ids = "mine/junk"; mockParent.getId.andReturn("mine");