[Search] Update tests and remove redundancy
Updated the generic provider test. Removed index checking from the generic search worker, because that checking is already done (more efficiently) in the generic search provider.
This commit is contained in:
@@ -81,6 +81,11 @@ define(
|
||||
);
|
||||
mockWorkerService.run.andReturn(mockWorker);
|
||||
|
||||
mockCapabilityPromise = jasmine.createSpyObj(
|
||||
"promise",
|
||||
[ "then", "catch" ]
|
||||
);
|
||||
|
||||
mockDomainObjects = {};
|
||||
for (i = 0; i < 4; i += 1) {
|
||||
mockDomainObjects[i] = (
|
||||
@@ -91,6 +96,7 @@ define(
|
||||
);
|
||||
mockDomainObjects[i].getId.andReturn(i);
|
||||
mockDomainObjects[i].getCapability.andReturn(mockCapability);
|
||||
mockDomainObjects[i].useCapability.andReturn(mockCapabilityPromise);
|
||||
}
|
||||
// Give the first object children
|
||||
mockDomainObjects[0].hasCapability.andReturn(true);
|
||||
@@ -98,10 +104,6 @@ define(
|
||||
"capability",
|
||||
[ "invoke", "listen" ]
|
||||
);
|
||||
mockCapabilityPromise = jasmine.createSpyObj(
|
||||
"promise",
|
||||
[ "then", "catch" ]
|
||||
);
|
||||
mockCapability.invoke.andReturn(mockCapabilityPromise);
|
||||
mockDomainObjects[0].getCapability.andReturn(mockCapability);
|
||||
|
||||
@@ -112,13 +114,30 @@ define(
|
||||
expect(mockObjectService.getObjects).toHaveBeenCalled();
|
||||
expect(mockObjectPromise.then).toHaveBeenCalled();
|
||||
|
||||
// Call through the root-getting part
|
||||
mockObjectPromise.then.mostRecentCall.args[0](mockDomainObjects);
|
||||
|
||||
//mockCapabilityPromise.then.mostRecentCall.args[0](mockDomainObjects[1]);
|
||||
// Call through the children-getting part
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockCapabilityPromise.then.mostRecentCall.args[0]([]);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
|
||||
expect(mockWorker.postMessage).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("when indexing, listens for composition changes", function () {
|
||||
var mockListener = {composition: {}};
|
||||
|
||||
// Call indexItems
|
||||
mockObjectPromise.then.mostRecentCall.args[0](mockDomainObjects);
|
||||
|
||||
// Call through listening for changes
|
||||
expect(mockCapability.listen).toHaveBeenCalled();
|
||||
mockCapability.listen.mostRecentCall.args[0](mockListener);
|
||||
expect(mockObjectService.getObjects).toHaveBeenCalled();
|
||||
mockObjectPromise.then.mostRecentCall.args[0](mockDomainObjects);
|
||||
});
|
||||
|
||||
it("sends search queries to the worker", function () {
|
||||
var timestamp = Date.now();
|
||||
provider.query(' test "query" ', timestamp, 1, 2);
|
||||
|
||||
Reference in New Issue
Block a user