chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'reflect-metadata';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { ListAuditQueryDto } from '../../src/audit/dto/list-audit-query.dto';
|
||||
import { AuditSource } from '../../src/database/entities';
|
||||
|
||||
test('ListAuditQueryDto transforms pagination and normalized enums', async () => {
|
||||
const dto = plainToInstance(ListAuditQueryDto, {
|
||||
page: '2',
|
||||
pageSize: '50',
|
||||
action: ' user_created ',
|
||||
source: 'web',
|
||||
from: '2026-08-01T00:00:00.000Z',
|
||||
});
|
||||
|
||||
assert.deepEqual(await validate(dto), []);
|
||||
assert.equal(dto.page, 2);
|
||||
assert.equal(dto.pageSize, 50);
|
||||
assert.equal(dto.action, 'USER_CREATED');
|
||||
assert.equal(dto.source, AuditSource.WEB);
|
||||
});
|
||||
|
||||
test('ListAuditQueryDto rejects oversized pages and invalid dates', async () => {
|
||||
const dto = plainToInstance(ListAuditQueryDto, {
|
||||
page: '0',
|
||||
pageSize: '500',
|
||||
from: 'fecha-invalida',
|
||||
});
|
||||
const properties = new Set((await validate(dto)).map((error) => error.property));
|
||||
|
||||
assert.equal(properties.has('page'), true);
|
||||
assert.equal(properties.has('pageSize'), true);
|
||||
assert.equal(properties.has('from'), true);
|
||||
});
|
||||
Reference in New Issue
Block a user