fix: close documented platform polish gaps
This commit is contained in:
@@ -4,6 +4,7 @@ function createPrismaMock() {
|
||||
return {
|
||||
phoneSegment: {
|
||||
findMany: jest.fn(),
|
||||
count: jest.fn().mockResolvedValue(3),
|
||||
},
|
||||
phoneCarrierRule: {
|
||||
findMany: jest.fn().mockResolvedValue([]),
|
||||
@@ -34,7 +35,7 @@ function createPrismaMock() {
|
||||
}
|
||||
|
||||
describe('DictionariesService', () => {
|
||||
it('paginates phone segments without counting the full table', async () => {
|
||||
it('paginates phone segments with a real database count', async () => {
|
||||
const prisma = createPrismaMock();
|
||||
prisma.phoneSegment.findMany.mockResolvedValue([
|
||||
{ id: 'segment-1', prefix: '1300001', carrier: '中国联通', province: '江苏', city: '常州' },
|
||||
@@ -43,25 +44,24 @@ describe('DictionariesService', () => {
|
||||
]);
|
||||
const service = new DictionariesService(prisma as never);
|
||||
|
||||
await expect(service.listPhoneSegments({ keyword: '中国联通', cursor: '1300000', pageSize: 2 })).resolves.toEqual({
|
||||
await expect(service.listPhoneSegments({ keyword: '中国联通', page: 2, pageSize: 2 })).resolves.toEqual({
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({ prefix: '1300001' }),
|
||||
expect.objectContaining({ prefix: '1300002' }),
|
||||
]),
|
||||
pageSize: 2,
|
||||
hasMore: true,
|
||||
nextCursor: '1300002',
|
||||
page: 2,
|
||||
total: 3,
|
||||
});
|
||||
expect(prisma.phoneSegment.findMany).toHaveBeenCalledWith({
|
||||
where: {
|
||||
AND: [
|
||||
{ prefix: { gt: '1300000' } },
|
||||
{ OR: expect.any(Array) },
|
||||
],
|
||||
OR: expect.any(Array),
|
||||
},
|
||||
orderBy: { prefix: 'asc' },
|
||||
take: 3,
|
||||
skip: 2,
|
||||
take: 2,
|
||||
});
|
||||
expect(prisma.phoneSegment.count).toHaveBeenCalledWith({ where: { OR: expect.any(Array) } });
|
||||
});
|
||||
|
||||
it('searches security control dictionaries with keyword and status filters', async () => {
|
||||
|
||||
Reference in New Issue
Block a user