import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import { irpcBook, irpcReportRows, irpcPreparationHtml, } from '../../resources/js/lib/irpc-withholdings.ts'; void test('each saved calculation identifies income category rate and Portuguese nature without recalculation', () => { const d = JSON.parse( fs.readFileSync( new URL( './fixtures/irpc-grouped-preserved.json', import.meta.url, ), 'utf8', ), ), before = JSON.stringify(irpcBook(d)), rows = irpcReportRows(d); assert.equal(rows.length, 6); for (const r of rows) { assert.match(r[2], /enquadramento:/); assert.match(r[2], /taxa:(10|20)%/); assert.match(r[3], /Retenção definitiva|Imposto por conta/); } assert.match(rows[2][2], /Propriedade intelectual\/industrial/); assert.match(rows[3][2], /Serviços de telecomunicações/); assert.match(rows[4][3], /Imposto por conta/); assert.match(rows[0][3], /Retenção definitiva/); assert.equal(JSON.stringify(irpcBook(d)), before); const html = irpcPreparationHtml(d); assert.match(html, /Retenção definitiva/); assert.match(html, /Imposto por conta/); assert.ok(!html.includes(';definitive;')); });