16 lines
848 B
TypeScript
16 lines
848 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { parseAnalyticsQuery } from './caller-analytics.service.js';
|
|
describe('analytics query boundary', () => {
|
|
it('rejects inverted, excessive and invalid date windows', () => {
|
|
for (const q of [{from:'bad'}, {from:'2026-01-01',to:'2026-02-01'}, {from:'2026-08-02',to:'2026-08-01'}]) expect(() => parseAnalyticsQuery(q)).toThrow();
|
|
});
|
|
it('rejects sort injection and mixed-grain vendor filters', () => {
|
|
expect(() => parseAnalyticsQuery({sort:'caller; DROP TABLE x'})).toThrow();
|
|
expect(() => parseAnalyticsQuery({view:'original',vendorGatewayId:'g'})).toThrow();
|
|
});
|
|
it('rejects invalid percentage and pagination values', () => {
|
|
expect(() => parseAnalyticsQuery({connectionMin:'101'})).toThrow();
|
|
expect(() => parseAnalyticsQuery({take:'1.5'})).toThrow();
|
|
});
|
|
});
|