Skip to content

Commit

Permalink
fixed failed test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
PurnenduMIshra129th committed Feb 1, 2025
1 parent a0d33d6 commit c47c565
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/resolvers/Query/getVolunteerRanks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("resolvers -> Query -> getVolunteerRanks", () => {
{},
)) as unknown as VolunteerRank[];

expect(volunteerRanks[0].hoursVolunteered).toEqual(6);
expect(volunteerRanks[0].hoursVolunteered).toEqual(2);
expect(volunteerRanks[0].user._id).toEqual(testUser1?._id);
expect(volunteerRanks[0].rank).toEqual(1);
});
Expand Down
6 changes: 3 additions & 3 deletions tests/resolvers/Query/verifyRole.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("verifyRole", () => {
}
});
test("should handle token without 'Bearer' prefix correctly", async () => {
const req = { headers: { authorization: "validToken" } };
const req = { headers: { authorization: `${token}` } };

if (verifyRole !== undefined) {
vi.spyOn(jwt, "verify").mockImplementationOnce(() => {
Expand Down Expand Up @@ -228,13 +228,13 @@ describe("verifyRole", () => {
});

test("should handle missing ACCESS_TOKEN_SECRET", async () => {
delete process.env.ACCESS_TOKEN_SECRET;
process.env.ACCESS_TOKEN_SECRET = undefined;
if (verifyRole !== undefined) {
const result = await verifyRole({}, {}, { req });
expect(result).toEqual({
role: "",
isAuthorized: false,
error: "Authentication failed",
error: "Invalid token",
});
// Restore ACCESS_TOKEN_SECRET
process.env.ACCESS_TOKEN_SECRET = "test_secret";
Expand Down

0 comments on commit c47c565

Please sign in to comment.