Skip to content

Commit

Permalink
refactor: mocking 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Conut-1 committed Oct 3, 2024
1 parent ab01d71 commit 9b114e8
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,20 @@ describe('RefreshTokensService', () => {
expiryDate: getExpiryDate({ week: 2 }),
userUuid: 'userId',
};
jest.spyOn(prisma.refreshToken, 'delete').mockResolvedValue(testToken);
(prisma.refreshToken.delete as jest.Mock).mockResolvedValue(testToken);

const token = service.deleteRefreshToken(testToken.token);

await expect(token).resolves.toEqual(testToken);
});

it('deleteRefreshToken not found', async () => {
jest
.spyOn(prisma.refreshToken, 'delete')
.mockRejectedValue(
new PrismaClientKnownRequestError(
'An operation failed because it depends on one or more records that were required but not found. Record to delete not found.',
{ code: 'P2025', clientVersion: '' },
),
);
(prisma.refreshToken.delete as jest.Mock).mockRejectedValue(
new PrismaClientKnownRequestError(
'An operation failed because it depends on one or more records that were required but not found. Record to delete not found.',
{ code: 'P2025', clientVersion: '' },
),
);

const token = service.deleteRefreshToken('Token');

Expand Down

0 comments on commit 9b114e8

Please sign in to comment.