Files
heidi/app/api/check/route.test.ts
CatoandClaude Opus 5.5 3e28a8d819 feat(dialect): regional forms from the literature, with links on every dialect page (#137)
Researched against the SDS digital edition (sprachatlas.ch), the Dialäktatlas
2025 and the regional grammars/dictionaries (links checked to resolve).

- Regional rules now cite sources (a test refuses one without); the SDS
  volume/map is in each reason. New: Wallis (appas, wier, wilt, Häärpfel,
  Aache, güet), Innerschweiz (Gumel, Eiker), Ostschweiz (näbis), Glarus
  (schüü), Sense (gùgge), Graubünden (eswas), Bern (iig, geisch, geit, Hung).
- Wrong claims removed: het, goht, stoht, nid, nit are attested inside the
  canton of Zurich (SDS 3/48, 3/57, 4/167) and d/t in 'Dütsch' is spelling
  (DWDS) — all now house style ('dispreferred'), no region named. sai, gäu,
  vilmau dropped (no source); güet re-filed as Wallis/Uri (SDS 1/142);
  Strassenbahn is Swiss spelling, no longer a 'Germany' form.
- Every area page lists its literature: 24 new sources (DNB/e-helvetica/DOI).
- Our own copy is checked at house-style level; the 'Which is Zurich?'
  exercise only quizzes forms the gate refuses outright.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 22:37:30 -07:00

47 lines
1.6 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { POST } from "./route.ts";
function request(body: unknown) {
return new Request("http://localhost/api/check", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify(body),
});
}
test("rejects empty input with 400", async () => {
const res = await POST(request({ text: "" }));
assert.equal(res.status, 400);
});
test("rejects over-long input with 400", async () => {
const res = await POST(request({ text: "a".repeat(2001) }));
assert.equal(res.status, 400);
});
test('returns violations for "Ig ha gseit, wosch es Miuch?"', async () => {
const res = await POST(request({ text: "Ig ha gseit, wosch es Miuch?" }));
assert.equal(res.status, 200);
const json = await res.json();
assert.equal(json.ok, false);
assert.ok(json.findings.length >= 2);
});
test('returns ok for "Das isch nöd guet"', async () => {
const res = await POST(request({ text: "Das isch nöd guet" }));
assert.equal(res.status, 200);
const json = await res.json();
assert.equal(json.ok, true);
assert.deepEqual(json.findings, []);
// Two taught forms (`isch`, a form of `si`, and `nöd`), nothing from elsewhere.
assert.equal(json.reading.verdict, "consistent");
});
test("the reading names the area a received message points to", async () => {
const res = await POST(request({ text: "Ig ha gseit, wosch es Miuch?" }));
const json = await res.json();
assert.equal(json.reading.verdict, "area");
assert.equal(json.reading.lead.origin, "Bern");
});