| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { isSuspensionHold, parseReason, suspensionHold } from "./suspension.ts"; |
| 5 | |
| 6 | test("a suspension's hold is known as one, so lifting it lifts the hold", () => { |
| 7 | const hold = suspensionHold(" card testing "); |
| 8 | assert.equal(hold, "Suspended: card testing"); |
| 9 | assert.ok(isSuspensionHold(hold)); |
| 10 | assert.ok(!isSuspensionHold("Unpaid invoice")); |
| 11 | assert.ok(!isSuspensionHold(null)); |
| 12 | }); |
| 13 | |
| 14 | test("a reason is required, and kept short", () => { |
| 15 | assert.deepEqual(parseReason(" spam sign-ups "), { ok: true, value: "spam sign-ups" }); |
| 16 | assert.equal(parseReason("x").ok, false); |
| 17 | assert.equal(parseReason("x".repeat(501)).ok, false); |
| 18 | }); |