From 3443c1c65e9f1753e1e656b35d08416c1fa298f2 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 00:14:38 +0200 Subject: worldmap-viewer: initial public history --- viewer/tests/modules.test.mjs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 viewer/tests/modules.test.mjs (limited to 'viewer/tests/modules.test.mjs') diff --git a/viewer/tests/modules.test.mjs b/viewer/tests/modules.test.mjs new file mode 100644 index 0000000..8565085 --- /dev/null +++ b/viewer/tests/modules.test.mjs @@ -0,0 +1,23 @@ +import './_planet.mjs'; +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { readdirSync, readFileSync, existsSync } from 'node:fs'; +import { HTML, IMPORTS } from './importmap.mjs'; + +const JS = new URL('../js/', import.meta.url); +const files = readdirSync(JS).filter(f => f.endsWith('.js')); + +test('import map targets exist', () => { + for (const v of Object.values(IMPORTS)) assert.ok(existsSync(new URL(v, new URL('../', import.meta.url))), v); +}); + +test('every viewer module links (imports resolve, named exports exist)', async () => { + for (const f of files) await import(new URL(f, JS).href); +}); + +test('every #id the scripts look up exists in index.html', () => { + const ids = new Set([...HTML.matchAll(/\bid="([\w-]+)"/g)].map(m => m[1])); + for (const f of files) { + for (const m of readFileSync(new URL(f, JS), 'utf8').matchAll(/\$\('#([\w-]+)'\)/g)) assert.ok(ids.has(m[1]), `${f}: #${m[1]}`); + } +}); -- cgit