From 0520f1c70cc5025529d0f7d995dee4d6528e7056 Mon Sep 17 00:00:00 2001 From: slhale Date: Wed, 12 Aug 2015 09:53:23 -0700 Subject: [PATCH] [Search] Update tests Test creation of the generic search provider provides mock timeout argument. Slight change to tree indexing test due to use of useCapability function. --- .../search/test/GenericSearchProviderSpec.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/search/test/GenericSearchProviderSpec.js b/platform/search/test/GenericSearchProviderSpec.js index acd5414d81..bec02653b8 100644 --- a/platform/search/test/GenericSearchProviderSpec.js +++ b/platform/search/test/GenericSearchProviderSpec.js @@ -31,6 +31,7 @@ define( describe("The generic search provider ", function () { var mockQ, + mockTimeout, mockDeferred, mockObjectService, mockObjectPromise, @@ -57,6 +58,8 @@ define( mockDeferred.promise = "mock promise"; mockQ.defer.andReturn(mockDeferred); + mockTimeout = jasmine.createSpy("$timeout"); + mockObjectService = jasmine.createSpyObj( "objectService", [ "getObjects" ] @@ -83,7 +86,7 @@ define( mockDomainObjects[i] = ( jasmine.createSpyObj( "domainObject", - [ "getId", "getModel", "hasCapability", "getCapability" ] + [ "getId", "getModel", "hasCapability", "getCapability", "useCapability" ] ) ); mockDomainObjects[i].getId.andReturn(i); @@ -102,14 +105,17 @@ define( mockCapability.invoke.andReturn(mockCapabilityPromise); mockDomainObjects[0].getCapability.andReturn(mockCapability); - provider = new GenericSearchProvider(mockQ, mockObjectService, mockWorkerService, mockRoots); + provider = new GenericSearchProvider(mockQ, mockTimeout, mockObjectService, mockWorkerService, mockRoots); }); it("indexes tree on initialization", function () { - mockObjectPromise.then.mostRecentCall.args[0](mockDomainObjects); - mockCapabilityPromise.then.mostRecentCall.args[0](mockDomainObjects[1]); - expect(mockObjectService.getObjects).toHaveBeenCalled(); + expect(mockObjectPromise.then).toHaveBeenCalled(); + + mockObjectPromise.then.mostRecentCall.args[0](mockDomainObjects); + + //mockCapabilityPromise.then.mostRecentCall.args[0](mockDomainObjects[1]); + expect(mockWorker.postMessage).toHaveBeenCalled(); });