UNPKG

@puq/testing

Version:

The library offers a collection of robust utilities designed to enhance test quality, streamline testing processes, and minimize the time and effort required for effective test implementation.

19 lines (18 loc) 680 B
import t from 'assert'; import { validate as o } from 'class-validator'; import { plainToInstance as r } from 'class-transformer'; import { extractConstraints as e } from './extract-constraints.js'; export async function transformAndValidate(l, a, n) { let s = r(l, a), c = e(await o(s)); try { if (n.length > 0) { for (let o of (t.equal(c.length, n.length), c))t.ok(n.includes(o)); for (let o of n)t.ok(c.includes(o)); } else c.length > 0 && console.error(c), t.equal(c.length, 0); } catch (t) { throw console.table({ constraints: c }), t; } } //# sourceMappingURL=transform-and-validate.js.map