| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { confirmsPurge, daysLeft, wentSummary } from "./deleted-workspaces.ts"; |
| 5 | |
| 6 | test("what went reads as one line", () => { |
| 7 | assert.equal( |
| 8 | wentSummary({ repositories: 3, projects: 1, members: 2, billing: null, protected: false }), |
| 9 | "3 repositories, 1 project, 2 members", |
| 10 | ); |
| 11 | assert.equal( |
| 12 | wentSummary({ repositories: 1, projects: 0, members: 1, billing: null, protected: false }), |
| 13 | "1 repository, 0 projects, 1 member", |
| 14 | ); |
| 15 | }); |
| 16 | |
| 17 | test("days left round up, and none once it is due", () => { |
| 18 | const now = Date.parse("2026-10-06T12:00:00Z"); |
| 19 | assert.equal(daysLeft("2026-11-05T12:00:00Z", now), 30); |
| 20 | assert.equal(daysLeft("2026-10-06T13:00:00Z", now), 1); |
| 21 | assert.equal(daysLeft("2026-10-06T12:00:00Z", now), 0); |
| 22 | assert.equal(daysLeft("2026-10-01T00:00:00Z", now), 0); |
| 23 | assert.equal(daysLeft("not a date", now), 0); |
| 24 | }); |
| 25 | |
| 26 | test("a purge is confirmed by the slug alone", () => { |
| 27 | assert.ok(confirmsPurge("acme", " Acme ")); |
| 28 | assert.ok(!confirmsPurge("acme", "")); |
| 29 | assert.ok(!confirmsPurge("acme", "acme-inc")); |
| 30 | }); |