| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { linkPaths } from "./compute.ts"; |
| 5 | |
| 6 | test("the page a refusal names becomes a link, without its full stop", () => { |
| 7 | assert.deepEqual(linkPaths("Deployments need a paid workspace. Start the $20 plan: /acme/-/billing"), [ |
| 8 | { text: "Deployments need a paid workspace. Start the $20 plan: " }, |
| 9 | { text: "/acme/-/billing", href: "/acme/-/billing" }, |
| 10 | ]); |
| 11 | assert.deepEqual(linkPaths("An owner can raise it: /acme/-/billing. Then try again."), [ |
| 12 | { text: "An owner can raise it: " }, |
| 13 | { text: "/acme/-/billing", href: "/acme/-/billing" }, |
| 14 | { text: ". Then try again." }, |
| 15 | ]); |
| 16 | }); |
| 17 | |
| 18 | test("text without a page, or with other slashes, stays text", () => { |
| 19 | assert.deepEqual(linkPaths("Try again in a minute."), [{ text: "Try again in a minute." }]); |
| 20 | assert.deepEqual(linkPaths("It reads src/-/x and a/b"), [{ text: "It reads src/-/x and a/b" }]); |
| 21 | }); |