Files
lislgosms/api/src/operations/client-operations.dto.spec.ts
T

29 lines
975 B
TypeScript

import { BadRequestException } from '@nestjs/common';
import { strictValidationPipe } from '../common/strict-validation.pipe';
import { ClientSystemLogExportDto } from './client-operations.dto';
describe('ClientSystemLogExportDto', () => {
it('accepts the supported date range and rejects extra or malformed fields', async () => {
await expect(
strictValidationPipe.transform(
{ createdAtFrom: '2026-08-21', createdAtTo: '2026-08-28', level: 'error' },
{
type: 'body',
metatype: ClientSystemLogExportDto,
data: undefined,
},
),
).resolves.toEqual(expect.objectContaining({ level: 'error' }));
await expect(
strictValidationPipe.transform(
{ createdAtFrom: 'last-week', tenantId: 'spoofed' },
{
type: 'body',
metatype: ClientSystemLogExportDto,
data: undefined,
},
),
).rejects.toBeInstanceOf(BadRequestException);
});
});