Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default { | ||
'/myindex/doc/bardoc1': { | ||
foo: 'bar', | ||
}, | ||
'/myindex/doc/bardoc2': { | ||
foo: 'bar', | ||
}, | ||
'/myindex/doc/notbar': { | ||
foo: 'something else', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { loadFixtures, unloadFixtures } from 'util/fixtures'; | ||
import fixtures from '../__fixtures__/getAllDocs'; | ||
import getAllDocs from '../getAllDocs'; | ||
|
||
beforeAll(async () => { | ||
await loadFixtures(fixtures); | ||
}); | ||
|
||
afterAll(() => unloadFixtures(fixtures)); | ||
|
||
it('fetches all docs in the index by default', async () => { | ||
const ids = []; | ||
for await (const { _id } of getAllDocs('myindex')) { | ||
ids.push(_id); | ||
} | ||
|
||
expect(ids).toEqual(expect.arrayContaining(['bardoc1', 'bardoc2', 'notbar'])); | ||
}); | ||
|
||
it('fetches only the doc that matches the query', async () => { | ||
const ids = []; | ||
for await (const { _id } of getAllDocs('myindex', { | ||
term: { foo: 'bar' }, | ||
})) { | ||
ids.push(_id); | ||
} | ||
|
||
expect(ids).toEqual(expect.arrayContaining(['bardoc1', 'bardoc2'])); | ||
expect(ids).not.toEqual(expect.arrayContaining(['notbar'])); | ||
}); |