@@ -1,15 +1,40 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readRows, exportProjectDossierCsv } from '../../resources/js/lib/project-dossier.ts';
|
||||
import {
|
||||
readRows,
|
||||
exportProjectDossierCsv,
|
||||
} from '../../resources/js/lib/project-dossier.ts';
|
||||
import { serializeFinancialToolsSnapshot } from '../../resources/js/lib/financial-calculators.ts';
|
||||
|
||||
test('structured planner tolerates incomplete or malformed snapshots', () => {
|
||||
void test('structured planner tolerates incomplete or malformed snapshots', () => {
|
||||
assert.deepEqual(readRows('not-json', ['name']), []);
|
||||
assert.deepEqual(readRows('{"x":1}', ['name']), []);
|
||||
});
|
||||
|
||||
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: '' }]) });
|
||||
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/);
|
||||
@@ -18,16 +43,28 @@ test('project export labels user market claims and insufficient finance evidence
|
||||
assert.match(csv, /Marco 1/);
|
||||
});
|
||||
|
||||
test('project dossier exports readable financial assumptions and verified calculator outputs', () => {
|
||||
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' },
|
||||
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' });
|
||||
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;/);
|
||||
|
||||
Reference in New Issue
Block a user