Skip to content

Commit 2e249a0

Browse files
committed
Add test
1 parent 50c5825 commit 2e249a0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

site/src/pages/UsersPage/UsersPage.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ describe("UsersPage", () => {
197197
expect(users.length).toEqual(3)
198198
})
199199

200+
201+
200202
describe("suspend user", () => {
201203
describe("when it is success", () => {
202204
it("shows a success message and refresh the page", async () => {
@@ -238,6 +240,28 @@ describe("UsersPage", () => {
238240
})
239241
})
240242

243+
describe("pagination", () => {
244+
it("goes to next and previous page", async () => {
245+
renderPage()
246+
const user = userEvent.setup()
247+
248+
const mock = jest
249+
.spyOn(API, "getUsers")
250+
.mockResolvedValueOnce([MockUser, MockUser2])
251+
252+
const nextButton = await screen.findByLabelText("Next page")
253+
await user.click(nextButton)
254+
255+
await waitFor(() => expect(API.getUsers).toBeCalledWith({ offset: 25, limit: 25, q: "" }))
256+
257+
mock.mockClear()
258+
const previousButton = await screen.findByLabelText("Previous page")
259+
await user.click(previousButton)
260+
261+
await waitFor(() => expect(API.getUsers).toBeCalledWith({ offset: 0, limit: 25, q: "" }))
262+
})
263+
})
264+
241265
describe("delete user", () => {
242266
describe("when it is success", () => {
243267
it("shows a success message and refresh the page", async () => {

0 commit comments

Comments
 (0)