fix: close sms scheduling and billing gaps
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { CertificationService } from './certification.service';
|
||||
|
||||
function createPrismaMock() {
|
||||
return {
|
||||
tenant: {
|
||||
findUnique: jest.fn().mockResolvedValue({ id: 'tenant-1' }),
|
||||
update: jest.fn().mockResolvedValue({ id: 'tenant-1', certificationStatus: 'pending' }),
|
||||
},
|
||||
enterpriseCertification: {
|
||||
create: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'cert-1', ...data })),
|
||||
findMany: jest.fn(),
|
||||
findUnique: jest.fn().mockResolvedValue({ id: 'cert-1', tenantId: 'tenant-1', status: 'pending' }),
|
||||
update: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'cert-1', ...data })),
|
||||
},
|
||||
user: {
|
||||
findUnique: jest.fn().mockResolvedValue({ id: 'reviewer-1' }),
|
||||
},
|
||||
operationLog: {
|
||||
create: jest.fn(),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('CertificationService', () => {
|
||||
it('submits certification and marks tenant pending', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new CertificationService(prisma as never);
|
||||
|
||||
await service.submit({ tenantId: 'tenant-1', companyName: '测试企业', licenseNo: 'LIC-1' });
|
||||
|
||||
expect(prisma.enterpriseCertification.create).toHaveBeenCalledWith({
|
||||
data: expect.objectContaining({ tenantId: 'tenant-1', companyName: '测试企业', status: 'pending' }),
|
||||
});
|
||||
expect(prisma.tenant.update).toHaveBeenCalledWith({
|
||||
where: { id: 'tenant-1' },
|
||||
data: { certificationStatus: 'pending' },
|
||||
});
|
||||
});
|
||||
|
||||
it('approves and rejects certification while syncing tenant status', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new CertificationService(prisma as never);
|
||||
|
||||
await service.approve('cert-1', { reviewerId: 'reviewer-1' });
|
||||
expect(prisma.tenant.update).toHaveBeenLastCalledWith({
|
||||
where: { id: 'tenant-1' },
|
||||
data: { certificationStatus: 'approved' },
|
||||
});
|
||||
|
||||
await service.reject('cert-1', { reviewerId: 'reviewer-1', reason: '资料不清晰' });
|
||||
expect(prisma.tenant.update).toHaveBeenLastCalledWith({
|
||||
where: { id: 'tenant-1' },
|
||||
data: { certificationStatus: 'rejected' },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user