test: revokeUserInvite test case added
This commit is contained in:
committed by
Andrew Bastin
parent
5368c52aab
commit
1df2520bf0
@@ -14,6 +14,7 @@ import {
|
||||
DUPLICATE_EMAIL,
|
||||
INVALID_EMAIL,
|
||||
USER_ALREADY_INVITED,
|
||||
USER_INVITATION_NOT_FOUND,
|
||||
} from '../errors';
|
||||
import { ShortcodeService } from 'src/shortcode/shortcode.service';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
@@ -134,6 +135,51 @@ describe('AdminService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('revokeUserInvite', () => {
|
||||
test('should resolve left and return error if email not invited', async () => {
|
||||
mockPrisma.invitedUsers.delete.mockRejectedValueOnce(new Error());
|
||||
|
||||
const result = await adminService.revokeUserInvite(
|
||||
'test@gmail.com',
|
||||
'adminUid',
|
||||
);
|
||||
|
||||
expect(result).toEqualLeft(USER_INVITATION_NOT_FOUND);
|
||||
});
|
||||
|
||||
test('should resolve right and return deleted invitee email', async () => {
|
||||
const adminUid = 'adminUid';
|
||||
mockPrisma.invitedUsers.delete.mockResolvedValueOnce(invitedUsers[0]);
|
||||
|
||||
const result = await adminService.revokeUserInvite(
|
||||
invitedUsers[0].inviteeEmail,
|
||||
adminUid,
|
||||
);
|
||||
|
||||
expect(mockPrisma.invitedUsers.delete).toHaveBeenCalledWith({
|
||||
where: {
|
||||
inviteeEmail: invitedUsers[0].inviteeEmail,
|
||||
},
|
||||
});
|
||||
expect(result).toEqualRight(true);
|
||||
});
|
||||
|
||||
test('should resolve right, delete invitee email and publish a subscription', async () => {
|
||||
const adminUid = 'adminUid';
|
||||
mockPrisma.invitedUsers.delete.mockResolvedValueOnce(invitedUsers[0]);
|
||||
|
||||
await adminService.revokeUserInvite(
|
||||
invitedUsers[0].inviteeEmail,
|
||||
adminUid,
|
||||
);
|
||||
|
||||
expect(mockPubSub.publish).toHaveBeenCalledWith(
|
||||
`admin/${adminUid}/invitation_revoked`,
|
||||
invitedUsers[0],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getUsersCount', () => {
|
||||
test('should return count of all users in the organization', async () => {
|
||||
mockUserService.getUsersCount.mockResolvedValueOnce(10);
|
||||
|
||||
Reference in New Issue
Block a user