Skip to content

Commit

Permalink
One more test
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Nov 20, 2024
1 parent e52407e commit 673d296
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/server/tests/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,35 @@ describe("updateUsername", () => {
expect(response.status).toBe(200)
expect(response.message).toBe("Username taken")
})

it("should return an error if there's a server error", async () => {
const newUsername = "newUsername"
const patronId = "678910"

const platformMethodMock = jest.fn().mockResolvedValueOnce({
status: 502,
type: "ils-integration-error",
})
;(nyplApiClient as jest.Mock).mockResolvedValueOnce({
post: platformMethodMock,
})

const response = await updateUsername(patronId, newUsername)

expect(nyplApiClient).toHaveBeenCalled
expect(platformMethodMock).toHaveBeenNthCalledWith(
1,
"/validations/username",
{
username: newUsername,
}
)

expect(sierraClient).not.toHaveBeenCalled

expect(response.status).toBe(500)
expect(response.message).toBe("Username update failed")
})
})

describe("renewCheckout", () => {
Expand Down

0 comments on commit 673d296

Please sign in to comment.