feat: optimize routing and operations views
This commit is contained in:
@@ -11,6 +11,8 @@ function createPrismaMock() {
|
||||
phoneCarrierRule: {
|
||||
findMany: jest.fn().mockResolvedValue([]),
|
||||
count: jest.fn().mockResolvedValue(0),
|
||||
create: jest.fn().mockImplementation(({ data }) => Promise.resolve({ id: 'rule-1', ...data })),
|
||||
delete: jest.fn().mockResolvedValue({ id: 'rule-1' }),
|
||||
},
|
||||
sensitiveWord: {
|
||||
findMany: jest.fn(),
|
||||
@@ -210,6 +212,17 @@ describe('DictionariesService', () => {
|
||||
expect(prisma.phoneCarrierRule.count).toHaveBeenCalledWith({ where: { OR: expect.any(Array) } });
|
||||
});
|
||||
|
||||
it('invalidates the sending cache after carrier rule changes', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const phoneRoutingLookup = { invalidateCarrierRules: jest.fn() };
|
||||
const service = new DictionariesService(prisma as never, phoneRoutingLookup as never);
|
||||
|
||||
await service.createPhoneCarrierRule({ carrier: 'mobile', pattern: '^138' });
|
||||
await service.deletePhoneCarrierRule('rule-1');
|
||||
|
||||
expect(phoneRoutingLookup.invalidateCarrierRules).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('creates and soft deletes blacklist and sensitive word entries with operation logs', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
const service = new DictionariesService(prisma as never);
|
||||
|
||||
Reference in New Issue
Block a user