chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'reflect-metadata';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { validate } from 'class-validator';
|
||||
import { CreateAssetDto } from '../../src/asset-master/dto/create-asset.dto';
|
||||
import { CreateAssetTypeDto } from '../../src/asset-master/dto/create-asset-type.dto';
|
||||
|
||||
const TYPE_ID = '16e54e65-60cf-4739-b0d1-ccdd904fbfd5';
|
||||
|
||||
test('CreateAssetTypeDto accepts a root type without fixed hierarchy levels', async () => {
|
||||
const dto = Object.assign(new CreateAssetTypeDto(), {
|
||||
code: 'empresa_operadora',
|
||||
name: 'Empresa operadora',
|
||||
description: 'Entidad administrable raíz',
|
||||
canBeRoot: true,
|
||||
allowedParentTypeIds: [],
|
||||
});
|
||||
assert.deepEqual(await validate(dto), []);
|
||||
});
|
||||
|
||||
test('CreateAssetDto validates identity, type and the attributes object', async () => {
|
||||
const dto = Object.assign(new CreateAssetDto(), {
|
||||
code: 'ACT-001',
|
||||
name: 'Activo de prueba',
|
||||
typeId: TYPE_ID,
|
||||
parentId: null,
|
||||
description: null,
|
||||
attributes: {},
|
||||
});
|
||||
assert.deepEqual(await validate(dto), []);
|
||||
|
||||
dto.code = 'código con espacios';
|
||||
const properties = new Set((await validate(dto)).map((error) => error.property));
|
||||
assert.equal(properties.has('code'), true);
|
||||
});
|
||||
Reference in New Issue
Block a user