feat: replace tenants with organization management
This commit is contained in:
30
apps/server/src/organizations/organizations.service.spec.ts
Normal file
30
apps/server/src/organizations/organizations.service.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { Repository } from 'typeorm';
|
||||
import { OrganizationsService } from './organizations.service';
|
||||
import { Organization } from '../entities/organization.entity';
|
||||
|
||||
describe('OrganizationsService — host organization rules', () => {
|
||||
let repo: jest.Mocked<
|
||||
Pick<Repository<Organization>, 'findOne' | 'find' | 'count' | 'create' | 'save' | 'update'>
|
||||
>;
|
||||
let service: OrganizationsService;
|
||||
|
||||
beforeEach(() => {
|
||||
repo = {
|
||||
findOne: jest.fn(),
|
||||
find: jest.fn(),
|
||||
count: jest.fn(),
|
||||
create: jest.fn(),
|
||||
save: jest.fn(),
|
||||
update: jest.fn(),
|
||||
} as any;
|
||||
service = new OrganizationsService(repo as Repository<Organization>);
|
||||
});
|
||||
|
||||
it('does not allow the host organization to be archived', async () => {
|
||||
repo.findOne.mockResolvedValue({ id: 1, name: '本机构', isHost: true } as Organization);
|
||||
|
||||
await expect(service.remove(1)).rejects.toBeInstanceOf(BadRequestException);
|
||||
expect(repo.update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user