Skip to content

Commit

Permalink
* improve pagination tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosexe committed Jun 7, 2024
1 parent 8474b8e commit d0ff29b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/app/api-common/src/paginationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ export async function getPaginatedEntries<T extends Record<string, unknown>>(
* @param apiCall
*
* @example
* &lt;caption>Example of usage with limit&lt;/caption>
* <caption>Example of usage with limit</caption>
* await getPaginatedEntries({ limit: 1 }, (params) => {
* return market.getApples(params)
* }
*
* &lt;caption>Example of usage with limit and start cursor&lt;/caption>
* <caption>Example of usage with limit and start cursor</caption>
* await getPaginatedEntries({ limit: 1, after: 'red' }, (params) => {
* return market.getApples(params)
* }
Expand Down
3 changes: 3 additions & 0 deletions packages/app/api-common/test/paginationUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ describe('paginationUtils', () => {
})

expect(spy).toHaveBeenCalledTimes(1)
expect(spy).toHaveBeenNthCalledWith(1, { limit: 1 })
expect(result).toEqual([])
})
it('should call api 2 time', async () => {
Expand Down Expand Up @@ -252,6 +253,8 @@ describe('paginationUtils', () => {
})

expect(spy).toHaveBeenCalledTimes(2)
expect(spy).toHaveBeenNthCalledWith(1, { limit: 1 })
expect(spy).toHaveBeenNthCalledWith(2, { after: 'red', limit: 1 })
expect(result).toEqual([{ id: 'red' }, { id: 'blue' }])
})
it('should respect initial cursor', async () => {
Expand Down

0 comments on commit d0ff29b

Please sign in to comment.