Skip to content

Commit d569d7e

Browse files
committed
increase test coverage
1 parent 1d1d926 commit d569d7e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/ParseQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ class ParseQuery<T extends ParseObject = ParseObject> {
16021602
* of the search
16031603
* */
16041604

1605-
async search(value: string, path: string[], options: SearchOptions = {}): Promise<Array<any>> {
1605+
async search(value: string, path: string[], options: SearchOptions = {}): Promise<T[]> {
16061606
if (!value) {
16071607
throw new Error('A search term is required.');
16081608
}

src/__tests__/ParseQuery-test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,19 @@ describe('ParseQuery', () => {
27432743
await expect(q.search(123)).rejects.toThrow('The value being searched for must be a string.');
27442744
});
27452745

2746+
it('search can return an empty array if no results', async () => {
2747+
CoreManager.setQueryController({
2748+
find() {},
2749+
aggregate() {
2750+
return Promise.resolve({});
2751+
},
2752+
});
2753+
2754+
const q = new ParseQuery('Item');
2755+
const results = await q.search('searchTerm', ['name'], { index: 'searchIndex' });
2756+
expect(results).toEqual([]);
2757+
});
2758+
27462759
it('aggregate query array pipeline with equalTo', done => {
27472760
const pipeline = [{ group: { objectId: '$name' } }];
27482761
MockRESTController.request.mockImplementationOnce(() => {

0 commit comments

Comments
 (0)