Skip to content

Commit

Permalink
fix(test): improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bandhan-majumder committed Mar 10, 2025
1 parent a2f8ee0 commit e53baca
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions tests/utilities/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import jwt from "jsonwebtoken";
import type mongoose from "mongoose";
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import type { InterfaceAppUserProfile, InterfaceUser } from "../../src/models";
import { AppUserProfile, Community, User } from "../../src/models";
import { AppUserProfile, Community } from "../../src/models";
import {
createAccessToken,
createRefreshToken,
Expand Down Expand Up @@ -231,18 +231,4 @@ describe("revokeRefreshToken", () => {

expect(updateAppUserProfile?.token).toBeUndefined();
});

it("should do nothing if the user does not exist", async () => {
const findOneSpy = vi.spyOn(User, "findOne").mockResolvedValueOnce(null);
const findOneAndUpdateSpy = vi.spyOn(User, "findOneAndUpdate");

const nonExistentUserId = "60c72b2f9b1d8a3e9c8d1234"; // Non-existent user ID
await revokeRefreshToken(nonExistentUserId);

expect(findOneSpy).toHaveBeenCalledWith({ _id: nonExistentUserId });
expect(findOneAndUpdateSpy).not.toHaveBeenCalled();

findOneSpy.mockRestore();
findOneAndUpdateSpy.mockRestore();
});
});

0 comments on commit e53baca

Please sign in to comment.