feat: unify signature channel reporting status
This commit is contained in:
@@ -25,6 +25,9 @@ function createPrismaMock() {
|
||||
create: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'enterprise-1', ...data })),
|
||||
update: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'enterprise-1', ...data })),
|
||||
},
|
||||
drainageField: {
|
||||
create: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'field-1', ...data })),
|
||||
},
|
||||
smsApplication: {
|
||||
findUnique: jest.fn().mockResolvedValue({ id: 'app-1', tenantId: 'tenant-1' }),
|
||||
},
|
||||
@@ -112,4 +115,17 @@ describe('DictionariesService', () => {
|
||||
});
|
||||
expect(prisma.enterpriseBlacklist.update).toHaveBeenCalledWith({ where: { id: 'enterprise-1' }, data: { status: 'deleted' } });
|
||||
});
|
||||
|
||||
it('only accepts string, image and file report field types', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new DictionariesService(prisma as never);
|
||||
|
||||
await expect(service.createDrainageField({ code: 'license', name: '营业执照', fieldType: 'image' })).resolves.toEqual(
|
||||
expect.objectContaining({ fieldType: 'image' }),
|
||||
);
|
||||
expect(() => service.createDrainageField({ code: 'amount', name: '数量', fieldType: 'number' as never })).toThrow(
|
||||
'fieldType must be string, image or file',
|
||||
);
|
||||
expect(prisma.drainageField.create).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ export interface CreateBlacklistDto {
|
||||
export interface CreateDrainageFieldDto {
|
||||
code: string;
|
||||
name: string;
|
||||
fieldType: string;
|
||||
fieldType: 'string' | 'image' | 'file';
|
||||
required?: boolean;
|
||||
status?: string;
|
||||
description?: string;
|
||||
@@ -255,6 +255,9 @@ export class DictionariesService {
|
||||
}
|
||||
|
||||
createDrainageField(data: CreateDrainageFieldDto) {
|
||||
if (!['string', 'image', 'file'].includes(data.fieldType)) {
|
||||
throw new BadRequestException('fieldType must be string, image or file');
|
||||
}
|
||||
return this.prisma.drainageField.create({
|
||||
data: {
|
||||
code: data.code,
|
||||
|
||||
Reference in New Issue
Block a user