worldmap-viewer

git clone https://git.godosa.eu/worldmap-viewer

master

raw ยท 948 bytes

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]}`);
  }
});