Skip to content

Commit

Permalink
Cover user not found case in admin role route tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lemilonkh committed Mar 11, 2024
1 parent 740cc54 commit 0a51f31
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/tests/api/admin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ describe("Admin API", () => {
assert.equal(user?.role, Roles.User);
});

it("should return a 404 error when user does not exist", async () => {
const req = mockRequest({
email: "[email protected]",
role: Roles.Admin,
});
Auth.getServerSession = mock.fn(() => Promise.resolve(mockAdminSession));
const res = await changeRole(req, { params: {} });
assert.equal(res.status, 404);
});

it("should validate the request", async () => {
Auth.getServerSession = mock.fn(() => Promise.resolve(mockAdminSession));
const req = mockRequest({ email: testUserData.email, role: "invalid" });
Expand Down

0 comments on commit 0a51f31

Please sign in to comment.