Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 913c2a4696514cd2049aa12215fc52d204dedfa2
parent c51e68ee1b4b04d43fffe32a8675a2ac6cfeddbc
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  5 Oct 2026 03:11:56 -0400

common: component tests pass children as props; VerdictChip tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/components/citations/citations.test.ts | 12++++++------
Acommon/components/report/VerdictChip.test.ts | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/common/components/citations/citations.test.ts b/common/components/citations/citations.test.ts @@ -160,29 +160,29 @@ test("the verification badge: a rounded percentage, voice, date; nothing when un }); test("an inline cite: the label links to what it cites, the number to its reference entry", () => { - const html = render(h(InlineCite, { citation: video }, "on stream")); + const html = render(h(InlineCite, { citation: video, children: "on stream" })); assert.match(html, /<a href="\/m\/demo-channel\/abc123\/3126.00-3151.00\/"[^>]*>on stream<\/a>/); assert.match(html, /<sup[^>]*><a href="#c-c01" data-cite-number="1" aria-label="Citation 1, video" aria-expanded="false"/); assert.ok(html.includes("[1]")); // closed: no preview in the server markup (it is portalled when opened) assert.ok(!html.includes("data-cite-preview")); // a page or a source opens off-site - assert.match(render(h(InlineCite, { citation: page }, "records")), /href="https:\/\/example.org\/city\/history" target="_blank" rel="noopener noreferrer"/); + assert.match(render(h(InlineCite, { citation: page, children: "records" })), /href="https:\/\/example.org\/city\/history" target="_blank" rel="noopener noreferrer"/); // an unresolved ref is its label alone - assert.equal(render(h(InlineCite, { citation: undefined }, "label")), "label"); + assert.equal(render(h(InlineCite, { citation: undefined, children: "label" })), "label"); }); test("cited markdown: cite links become inline cites, other links stay links, code stays code", () => { const md = "He said so [on stream](cite:c01), the [city](cite:w01) agrees; see [elsewhere](https://example.org/z) and `[x](cite:c01)`."; - const html = render(h(CitedMarkdown, { citations: byId }, md)); + const html = render(h(CitedMarkdown, { citations: byId, children: md })); assert.match(html, /data-inline-cite="c01"/); assert.match(html, /data-inline-cite="w01"/); assert.match(html, /\[1\]/); assert.match(html, /\[5\]/); - assert.match(html, /<a href="https:\/\/example.org\/z" target="_blank" rel="noopener noreferrer"[^>]*>elsewhere<\/a>/); + assert.match(html, /<a [^>]*href="https:\/\/example.org\/z" target="_blank" rel="noopener noreferrer"[^>]*>elsewhere<\/a>/); assert.match(html, /<code[^>]*>\[x\]\(cite:c01\)<\/code>/); // an id the map lacks renders as its label - assert.ok(render(h(CitedMarkdown, { citations: {} }, "[gone](cite:zz)")).includes("gone")); + assert.ok(render(h(CitedMarkdown, { citations: {}, children: "[gone](cite:zz)" })).includes("gone")); assert.equal(citeIdOf("cite:c01"), "c01"); assert.equal(citeIdOf("https://x"), null); }); diff --git a/common/components/report/VerdictChip.test.ts b/common/components/report/VerdictChip.test.ts @@ -0,0 +1,37 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import * as React from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { resolveVerdicts } from "../../lib/report/verdicts"; +import { VerdictChip, VerdictTally } from "./VerdictChip"; + +(globalThis as { React?: typeof React }).React = React; +const h = React.createElement; + +const styles = resolveVerdicts({ PARTLY: { label: "Half true", color: "#123456" } }); + +test("a chip: the verdict's label, its colour as the chip's mark, a count when given", () => { + const html = renderToStaticMarkup(h(VerdictChip, { verdict: "PARTLY", style: styles.PARTLY, count: 3 })); + assert.match(html, /data-verdict="PARTLY"/); + assert.match(html, /style="--verdict:#123456"/); + assert.ok(html.includes("Half true")); + assert.match(html, />3<\/span>/); +}); + +test("a tally: one chip per verdict given, nothing for none", () => { + const html = renderToStaticMarkup( + h(VerdictTally, { + tally: [ + { verdict: "CORROBORATED", count: 2 }, + { verdict: "CONTRADICTED", count: 1 }, + ], + styles, + }), + ); + assert.deepEqual( + [...html.matchAll(/data-verdict="([A-Z_]+)"/g)].map((m) => m[1]), + ["CORROBORATED", "CONTRADICTED"], + ); + assert.ok(html.includes("Corroborated")); + assert.equal(renderToStaticMarkup(h(VerdictTally, { tally: [], styles })), ""); +});