Skip to content

Commit

Permalink
test: 테스트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Conut-1 committed Dec 12, 2024
1 parent eebefdf commit 7f81919
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion nestjs-BE/server/src/invite-codes/invite-codes.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,25 @@ describe('InviteCodesService', () => {

beforeEach(() => {
profileSpaceService.isProfileInSpace = jest.fn(async () => true);
prisma.$transaction = jest.fn(async () => undefined);
(prisma.$transaction as jest.Mock) = jest.fn(async (callback) =>
callback(),
);
jest.spyOn(inviteCodesService, 'findInviteCode').mockResolvedValue(null);
(prisma.inviteCode.create as jest.Mock) = jest.fn(
async () => testInviteCode,
);
});

it('created', async () => {
const inviteCode = inviteCodesService.createInviteCode(
testProfileUuid,
testSpaceUuid,
);

await expect(inviteCode).resolves.toEqual(testInviteCode);
expect(inviteCodesService.findInviteCode).toHaveBeenCalledTimes(1);
});

it('space not found', async () => {
(profileSpaceService.isProfileInSpace as jest.Mock).mockResolvedValue(
false,
Expand Down

0 comments on commit 7f81919

Please sign in to comment.