Skip to content

Commit 8bb9abd

Browse files
committed
Fix pagination test
1 parent 66386d1 commit 8bb9abd

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

packages/autocomplete-client/src/search/__tests__/fetchMeilisearchResults.test.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77
import { HIGHLIGHT_PRE_TAG, HIGHLIGHT_POST_TAG } from '../../constants'
88

99
type Movie = (typeof MOVIES)[number]
10+
1011
const INDEX_NAME = 'movies'
12+
const FIRST_ITEM_ID = MOVIES[0].id
13+
const SECOND_ITEM_ID = MOVIES[1].id
1114

1215
beforeAll(async () => {
1316
await meilisearchClient.deleteIndex(INDEX_NAME)
@@ -31,27 +34,27 @@ describe('fetchMeilisearchResults', () => {
3134
],
3235
})
3336

34-
expect(results[0].hits[0].id).toEqual(2)
35-
expect(results[0].hits[1].id).toEqual(5)
37+
expect(results[0].hits[0].id).toEqual(FIRST_ITEM_ID)
38+
expect(results[0].hits[1].id).toEqual(SECOND_ITEM_ID)
3639
})
3740

38-
// test('with custom pagination', async () => {
39-
// const results = await fetchMeilisearchResults({
40-
// searchClient,
41-
// queries: [
42-
// {
43-
// indexName: INDEX_NAME,
44-
// query: 'Hit',
45-
// params: {
46-
// hitsPerPage: 1,
47-
// page: 1,
48-
// },
49-
// },
50-
// ],
51-
// })
41+
test('with custom pagination', async () => {
42+
const results = await fetchMeilisearchResults({
43+
searchClient,
44+
queries: [
45+
{
46+
indexName: INDEX_NAME,
47+
query: '',
48+
params: {
49+
hitsPerPage: 1,
50+
page: 1, // pages start at 0
51+
},
52+
},
53+
],
54+
})
5255

53-
// expect(results[0].hits[0].id).toEqual(2)
54-
// })
56+
expect(results[0].hits[0].id).toEqual(SECOND_ITEM_ID)
57+
})
5558

5659
// test('with custom highlight tags', async () => {
5760
// const results = await fetchMeilisearchResults({

0 commit comments

Comments
 (0)