fix(opportunities): distinguish missing verification and improve metadata
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
opportunityDescription,
|
||||
recordedVerificationDate,
|
||||
} from '../../resources/js/lib/opportunity-information.ts';
|
||||
|
||||
test('metadata uses the actual summary, normalises markup and never invents investment terms', () => {
|
||||
assert.equal(opportunityDescription({ title: 'Projecto', summary: '<b>Resumo</b>\n declarado' }), 'Resumo declarado');
|
||||
const fallback = opportunityDescription({ title: 'Avicultura', summary: null });
|
||||
assert.match(fallback, /Avicultura/);
|
||||
assert.match(opportunityDescription({ title: 'Projecto', summary: '<b> </b>' }), /Projecto/);
|
||||
assert.doesNotMatch(fallback, /A negociar|USD|aprovad|benefício/i);
|
||||
assert.equal(Array.from(opportunityDescription({ title: 'Projecto', summary: 'a'.repeat(300) })).length, 160);
|
||||
});
|
||||
|
||||
test('unknown and invalid verification dates remain distinct from a recorded verification', () => {
|
||||
assert.equal(recordedVerificationDate(null), 'Não registada');
|
||||
assert.equal(recordedVerificationDate('invalid'), 'Data não interpretável');
|
||||
assert.equal(recordedVerificationDate('2026-02-30T12:00:00Z'), 'Data não interpretável');
|
||||
assert.equal(recordedVerificationDate('2026-11-10 12:00:00'), 'Fuso horário não registado');
|
||||
assert.match(recordedVerificationDate('2026-11-10T12:00:00Z'), /2026/);
|
||||
});
|
||||
Reference in New Issue
Block a user