mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-01 10:27:30 +00:00
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { INestApplication, ConflictException, BadRequestException } from '@nestjs/common';
|
|
import { GroupPermissionsService } from '@services/group_permissions.service';
|
|
import { clearDB, createNestAppInstance, setupOrganization } from '../test.helper';
|
|
|
|
describe('GroupPermissionsService', () => {
|
|
let service: GroupPermissionsService;
|
|
let nestApp: INestApplication;
|
|
|
|
beforeEach(async () => {
|
|
await clearDB();
|
|
});
|
|
|
|
beforeAll(async () => {
|
|
nestApp = await createNestAppInstance();
|
|
service = nestApp.get<GroupPermissionsService>(GroupPermissionsService);
|
|
});
|
|
|
|
describe('.create', () => {
|
|
it('should pass group name', async () => {
|
|
const { adminUser } = await setupOrganization(nestApp);
|
|
|
|
await expect(service.create(adminUser, '')).rejects.toEqual(
|
|
new BadRequestException('Cannot create group without name')
|
|
);
|
|
});
|
|
|
|
it('should validate uniqueness of group permission group name', async () => {
|
|
const { adminUser } = await setupOrganization(nestApp);
|
|
|
|
await service.create(adminUser, 'avengers');
|
|
|
|
await expect(service.create(adminUser, 'avengers')).rejects.toEqual(
|
|
new ConflictException('Group name already exist')
|
|
);
|
|
});
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await nestApp.close();
|
|
});
|
|
});
|