26 lines1,015 bytesCodeBlame
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { trialClosed } from "./trial.ts";
5
6const base = { usedMicros: 0, limitMicros: 1_000_000, endsAt: null };
7
8test("an open trial says nothing", () => {
9 assert.equal(trialClosed({ ...base, open: true, reason: null }, "acme"), null);
10 assert.equal(trialClosed(null, "acme"), null);
11});
12
13test("a spent trial and a given-out month say so", () => {
14 assert.equal(trialClosed({ ...base, open: false, reason: "used" }, "acme"), "acme has used its trial credit on g1t.");
15 assert.equal(
16 trialClosed({ ...base, open: false, reason: "pool", waitsUntil: "2026-11-01T00:00:00Z" }, "acme"),
17 "This month's free trials are all given out; new ones start on November 1.",
18 );
19});
20
21test("a workspace without a card check is told it needs one", () => {
22 assert.equal(
23 trialClosed({ ...base, open: false, reason: "verify" as never }, "acme"),
24 "acme needs a card check before its trial starts. The card is never charged.",
25 );
26});