web/website/tests/dunemark-art.test.mjs

17 lines
1.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {existsSync,readFileSync} from 'node:fs';
import {NOTE_SERIES,COIN_SERIES,renderDunemarkCollection} from '../control-panel/public/cp-v2/dunemark-catalogue.mjs';
const web=new URL('../web/',import.meta.url);
test('Postbank catalogue includes all nine notes, ten coins and two commemoratives',()=>{
assert.deepEqual(NOTE_SERIES.map(x=>x[0]),[5,10,20,50,100,200,500,1000,5000]);assert.equal(COIN_SERIES.length,10);
const html=renderDunemarkCollection();assert.match(html,/Federal Imperial Reserve/);assert.doesNotMatch(html,/Vaerkring Reserve/);
for(const [value]of NOTE_SERIES)assert.ok(existsSync(new URL('assets/currency/note-'+value+'.png',web)));
for(const [id]of COIN_SERIES)assert.ok(existsSync(new URL('assets/currency/coin-'+id+'.png',web)));
for(const id of ['leto','house']){assert.ok(existsSync(new URL('assets/currency/note-0-'+id+'.png',web)));assert.match(html,new RegExp('dm-zero-'+id));}
assert.match(html,/Ut vivat, crescat et floreat DuneRealms/);assert.match(html,/No cash value/);
});
test('Exchange has no collection duplicate; manual points to Postbank',()=>{
assert.doesNotMatch(readFileSync(new URL('exchange.html',web),'utf8'),/id="dunemark-art"|class="dm-collection"/);
const chapter=JSON.parse(readFileSync(new URL('manual-data.json',web),'utf8')).find(c=>c.id==='solaris-spice-sales-and-guild-travel');assert.match(chapter.body,/#bank\/dunemark-collection/);assert.doesNotMatch(chapter.body,/id="dunemark-art"/);
});