"use strict";
const test = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const I = require("../static/i18n.js");

const html = fs.readFileSync(path.join(__dirname, "../static/index.html"), "utf8");

test("index.html includes the i18n script and a language select", () => {
  assert.match(html, /<script src="\/i18n\.js">/);
  assert.match(html, /id="lang-select"/);
});

test("every data-i18n key in index.html exists in UI_STRINGS", () => {
  const keys = [...html.matchAll(/data-i18n="([^"]+)"/g)].map((m) => m[1]);
  assert.ok(keys.length >= 12, `expected many tagged nodes, found ${keys.length}`);
  for (const k of keys) assert.ok(I.UI_STRINGS[k], `data-i18n key not in catalog: ${k}`);
});
