|
| 1 | +import { instantMeiliSearch } from '../src' |
1 | 2 | import { searchClient, dataset, Movies } from './assets/utils'
|
2 | 3 |
|
3 | 4 | describe('Pagination browser test', () => {
|
@@ -97,4 +98,55 @@ describe('Pagination browser test', () => {
|
97 | 98 | expect(hits.length).toBe(0)
|
98 | 99 | expect(hits).toEqual([])
|
99 | 100 | })
|
| 101 | + |
| 102 | + test('Test pagination total hits ', async () => { |
| 103 | + const customClient = instantMeiliSearch( |
| 104 | + 'http://localhost:7700', |
| 105 | + 'masterKey', |
| 106 | + { |
| 107 | + paginationTotalHits: 1, |
| 108 | + } |
| 109 | + ) |
| 110 | + const response = await customClient.search<Movies>([ |
| 111 | + { |
| 112 | + indexName: 'movies', |
| 113 | + }, |
| 114 | + ]) |
| 115 | + const hits = response.results[0].hits |
| 116 | + expect(hits.length).toBe(1) |
| 117 | + }) |
| 118 | + |
| 119 | + test('Test zero pagination total hits ', async () => { |
| 120 | + const customClient = instantMeiliSearch( |
| 121 | + 'http://localhost:7700', |
| 122 | + 'masterKey', |
| 123 | + { |
| 124 | + paginationTotalHits: 0, |
| 125 | + } |
| 126 | + ) |
| 127 | + const response = await customClient.search<Movies>([ |
| 128 | + { |
| 129 | + indexName: 'movies', |
| 130 | + }, |
| 131 | + ]) |
| 132 | + const hits = response.results[0].hits |
| 133 | + expect(hits.length).toBe(0) |
| 134 | + }) |
| 135 | + |
| 136 | + test('Test bigger pagination total hits than nbr hits', async () => { |
| 137 | + const customClient = instantMeiliSearch( |
| 138 | + 'http://localhost:7700', |
| 139 | + 'masterKey', |
| 140 | + { |
| 141 | + paginationTotalHits: 1000, |
| 142 | + } |
| 143 | + ) |
| 144 | + const response = await customClient.search<Movies>([ |
| 145 | + { |
| 146 | + indexName: 'movies', |
| 147 | + }, |
| 148 | + ]) |
| 149 | + const hits = response.results[0].hits |
| 150 | + expect(hits.length).toBe(6) |
| 151 | + }) |
100 | 152 | })
|
0 commit comments