diff options
| author | godosa <godosa@godosa.eu> | 2026-10-07 00:14:38 +0200 |
|---|---|---|
| committer | godosa <godosa@godosa.eu> | 2026-10-07 00:14:38 +0200 |
| commit | 3443c1c65e9f1753e1e656b35d08416c1fa298f2 (patch) | |
| tree | 4e43236f460145a4d75d1b4616dcb7aa6ef08f51 /viewer/tests/modules.test.mjs | |
| download | worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.tar.gz worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.zip | |
worldmap-viewer: initial public history
Diffstat (limited to 'viewer/tests/modules.test.mjs')
| -rw-r--r-- | viewer/tests/modules.test.mjs | 23 |
1 files changed, 23 insertions, 0 deletions
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]}`); + } +}); |
