Files
Investidor-V2/tests/frontend/project-dossier.test.mjs
T
nala 1106509116
tests / ci (push) Canceled after 0s
vrsao 2
2026-10-08 14:02:01 +02:00

73 lines
2.6 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
readRows,
exportProjectDossierCsv,
} from '../../resources/js/lib/project-dossier.ts';
import { serializeFinancialToolsSnapshot } from '../../resources/js/lib/financial-calculators.ts';
void test('structured planner tolerates incomplete or malformed snapshots', () => {
assert.deepEqual(readRows('not-json', ['name']), []);
assert.deepEqual(readRows('{"x":1}', ['name']), []);
});
void test('project export labels user market claims and insufficient finance evidence', () => {
const csv = exportProjectDossierCsv({
market_assumption: 'procura alta',
market_source: '',
project_title: '=1+1',
project_team_snapshot: JSON.stringify([
{
competency: 'Gestão',
state: 'gap',
action: 'Formação',
estimated_cost: '20',
due_date: '',
},
]),
project_execution_snapshot: JSON.stringify([
{
title: 'Abrir',
due_date: '',
status: 'planned',
planned_amount: '10',
actual_amount: '',
},
]),
});
assert.match(csv, /Informação declarada, não verificada/);
assert.match(csv, /Informação insuficiente/);
assert.match(csv, /'=1\+1/);
assert.match(csv, /Secção;Campo;Valor;Origem \/ estado/);
assert.match(csv, /Gestão; gap; resposta: Formação/);
assert.match(csv, /Marco 1/);
});
void test('project dossier exports readable financial assumptions and verified calculator outputs', () => {
const financial_tools_snapshot = serializeFinancialToolsSnapshot({
budgetPeriod: 'Mensal',
loan: {
principal: '100000',
rate: '18',
months: '24',
rateType: 'nominal',
periodMonths: '1',
gracePeriods: '0',
upfrontFee: '0',
recurringFee: '0',
},
breakEven: { fixed: '50000', price: '1000', variable: '600' },
funding: { total: '1000000', secured: '250000' },
incomes: [{ label: 'Vendas', amount: '200000' }],
expenses: [{ label: 'Operação', amount: '150000' }],
});
const csv = exportProjectDossierCsv({
financial_tools_snapshot,
currency: 'MZN',
});
assert.match(csv, /Unidades estimadas;125;/);
assert.match(csv, /Diferença por financiar;750000\.00 MZN;/);
assert.match(csv, /Saldo operacional estimado;50000\.00 MZN;/);
assert.doesNotMatch(csv, /"\{""version""/);
});