Skip to content

Commit

Permalink
fix: invitation service unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
boris-w committed Jan 7, 2025
1 parent 3736055 commit 5d9e192
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('InvitationService', () => {
id: mockInvitationId,
invitationCode: mockInvitationCode,
} as any);
vi.spyOn(collaboratorService, 'validateUserAddRole').mockResolvedValue();
collaboratorService.validateUserAddRole.mockResolvedValue();

const result = await clsService.runWith(
{
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('InvitationService', () => {
prismaService.space.findFirst.mockResolvedValue(mockSpace as any);
prismaService.user.findMany.mockResolvedValue([mockInvitedUser as any]);
prismaService.$tx.mockRejectedValue(new Error('tx error'));
vi.spyOn(collaboratorService, 'validateUserAddRole').mockResolvedValue();
collaboratorService.validateUserAddRole.mockResolvedValue();
vi.spyOn(invitationService as any, 'checkSpaceInvitation').mockResolvedValue(true);

await clsService.runWith(
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('InvitationService', () => {
id: mockInvitationId,
invitationCode: mockInvitationCode,
} as any);
vi.spyOn(collaboratorService, 'validateUserAddRole').mockResolvedValue();
collaboratorService.validateUserAddRole.mockResolvedValue();

const result = await clsService.runWith(
{
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('InvitationService', () => {
prismaService.base.findFirst.mockResolvedValue({ id: 'base1' } as any);
prismaService.user.findMany.mockResolvedValue([mockInvitedUser as any]);
prismaService.$tx.mockRejectedValue(new Error('tx error'));
vi.spyOn(collaboratorService, 'validateUserAddRole').mockResolvedValue();
collaboratorService.validateUserAddRole.mockResolvedValue();
vi.spyOn(invitationService as any, 'checkSpaceInvitation').mockResolvedValue(true);
await clsService.runWith(
{
Expand Down Expand Up @@ -401,8 +401,12 @@ describe('InvitationService', () => {
},
});
expect(collaboratorService.createSpaceCollaborator).toHaveBeenCalledWith({
principalId: mockUser.id,
principalType: PrincipalType.User,
collaborators: [
{
principalId: mockUser.id,
principalType: PrincipalType.User,
},
],
spaceId: mockSpace.id,
role: Role.Owner,
createdBy: 'createdBy',
Expand Down

0 comments on commit 5d9e192

Please sign in to comment.