Skip to content

Commit

Permalink
Add tests for getPaginationOffsetStrings
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcohen committed Nov 21, 2023
1 parent 7ee68a5 commit 1cf7e43
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/utils/utilsTests/searchUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
getPaginationOffsetStrings,
getQueryString,
mapQueryToSearchParams,
mapRequestBodyToSearchParams,
Expand Down Expand Up @@ -74,4 +75,21 @@ describe("searchUtils", () => {
})
})
})
describe("getPaginationOffsetStrings", () => {
it("returns a tuple of strings with the correct start and end values for the first page", () => {
const [start, end] = getPaginationOffsetStrings(1, 1200)
expect(start).toEqual("1")
expect(end).toEqual("50")
})
it("returns a tuple of strings with the correct start and end values for any given page", () => {
const [start, end] = getPaginationOffsetStrings(5, 1200)
expect(start).toEqual("201")
expect(end).toEqual("250")
})
it("correctly sets the end value for the last page", () => {
const [start, end] = getPaginationOffsetStrings(24, 1195)
expect(start).toEqual("1,151")
expect(end).toEqual("1,195")
})
})
})

0 comments on commit 1cf7e43

Please sign in to comment.