From 1cf7e43e90a62f2090443525f93cb975bd1984ca Mon Sep 17 00:00:00 2001 From: Diego Cohen Date: Tue, 21 Nov 2023 12:46:38 -0500 Subject: [PATCH] Add tests for getPaginationOffsetStrings --- src/utils/utilsTests/searchUtils.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/utils/utilsTests/searchUtils.test.ts b/src/utils/utilsTests/searchUtils.test.ts index eded14986..07f996904 100644 --- a/src/utils/utilsTests/searchUtils.test.ts +++ b/src/utils/utilsTests/searchUtils.test.ts @@ -1,4 +1,5 @@ import { + getPaginationOffsetStrings, getQueryString, mapQueryToSearchParams, mapRequestBodyToSearchParams, @@ -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") + }) + }) })