[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.
This commit is contained in:
slhale 2015-08-12 09:53:23 -07:00
parent 3b62f1a979
commit 0520f1c70c

View File

@ -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();
});