fix: close sms scheduling and billing gaps

This commit is contained in:
hectorzhao
2026-07-01 18:56:05 +08:00
parent 8ba4ef8a13
commit f8c9b78c21
28 changed files with 1480 additions and 26 deletions
@@ -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' },
});
});
});