home / client / test / glyphs.test.mjs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// The catalog glyphs, byte for byte, plus every glyphFor branch.
import test from "node:test";
import assert from "node:assert/strict";
import { boot, vectors } from "./harness.mjs";

const { lib } = await boot();
const v = vectors("glyphs");

test("the GLYPHS map has the same keys as the TS object", () => {
  assert.deepEqual([...lib.glyphKeys()], v.keys);
});

test("every glyph's SVG source is byte-identical", () => {
  const map = lib.glyphMap();
  for (const k of v.keys) assert.equal(map[k], v.map[k], `glyph ${k}`);
});

test("catalogGlyph: the accent diamond, valid accents and the sage fallback", () => {
  for (const [accent, want] of Object.entries(v.accents)) {
    assert.equal(lib.catalogGlyph(accent), want, `accent ${JSON.stringify(accent)}`);
  }
});

test("glyphFor: override > named glyph > accent diamond, over every case", () => {
  v.script.forEach((entry, i) => {
    assert.equal(lib.glyphFor(entry), v.out[i], `case ${i}: ${JSON.stringify(entry)}`);
  });
});

test("a prototype key falls through to the diamond (the TS quirk, fixed)", () => {
  // GLYPHS is a CLJS map here, not a plain object, so "__proto__" has no
  // prototype-chain hit — the TS returned Object.prototype and painted
  // "[object Object]". The fixture recorded that; the port improves on it.
  assert.equal(v.protoQuirk.tsReturnedAString, false, "the fixture must still record the TS quirk");
  assert.equal(lib.glyphFor(v.protoQuirk.entry), v.protoQuirk.cljsMustReturn);
});

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/home.git