Files
dh-inspeccion-v2/api-v3/test/unit/asset-registry-dto.test.ts

29 lines
1.5 KiB
TypeScript

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 { AddOrganizationMembershipDto } from '../../src/asset-master/dto/add-organization-membership.dto';
import { CreateExternalIdentifierDto } from '../../src/asset-master/dto/create-external-identifier.dto';
import { UpsertOrganizationProfileDto } from '../../src/asset-master/dto/upsert-organization-profile.dto';
const uuid = '550e8400-e29b-41d4-a716-446655440000';
test('D5.3.3 organization profile accepts explicit UTE kind', async () => {
const dto = plainToInstance(UpsertOrganizationProfileDto, { organizationKind:'UTE', legalName:'UTE Prueba' });
assert.equal((await validate(dto)).length, 0);
});
test('D5.3.3 membership validates participant percentage', async () => {
const valid = plainToInstance(AddOrganizationMembershipDto, { memberOrganizationId:uuid, role:'MEMBER', participationPercent:50 });
assert.equal((await validate(valid)).length, 0);
const invalid = plainToInstance(AddOrganizationMembershipDto, { memberOrganizationId:uuid, role:'MEMBER', participationPercent:101 });
assert.ok((await validate(invalid)).length > 0);
});
test('D5.3.3 external identifiers normalize namespace', async () => {
const dto = plainToInstance(CreateExternalIdentifierDto, { namespace:'sen', value:'12345' });
assert.equal(dto.namespace, 'SEN');
assert.equal((await validate(dto)).length, 0);
});