web/website/tests/rates-reference.test.mjs

15 lines
1.4 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {readFileSync} from 'node:fs';
import {ratesReferenceSections,ratesReferenceHTML} from '../scripts/rates-reference.mjs';
import {bankRatesPage} from '../scripts/bank-rates-page.mjs';
test('complete tariff handbook covers implemented formulas, availability, payers and destinations without exposing developer codes',()=>{
const sections=ratesReferenceSections(),html=bankRatesPage();
for(const id of ['tax-rules','publication-charges','reserve-instruments','economy-formulas','payroll-formulas'])assert(sections.some(s=>s.id===id));
assert.match(html,/Download complete guide/);assert.match(html,/ECO-SNAP/);assert.match(html,/Server\/CLI only/);assert.match(html,/not enabled by publishing/);assert.match(html,/3,000 DM/);
assert(!html.includes('DEV-BATCH.'));assert(!html.includes('DB_PASSWORD'));assert.match(ratesReferenceHTML(),/Tax treasury/);
assert.equal(sections.filter(s=>s.id.startsWith('guide-claims-')).length,3);
});
test('download references the public financial snapshot and ships a real PDF',()=>{
const manifest=JSON.parse(readFileSync(new URL('../web/downloads/rates-guide-manifest.json',import.meta.url),'utf8'));
assert.match(manifest.sourcePublicationVersion,/^[a-f0-9-]{36}$/i);
const pdf=readFileSync(new URL('../web'+manifest.pdf,import.meta.url));assert.equal(pdf.subarray(0,5).toString(),'%PDF-');assert(pdf.length>20000);
});