| 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(wentSummary({ repositories: 3, projects: 1, members: 2, billing: null, protected: false }), "3 repositories, 1 project, 2 members"); |
| 8 | assert.equal(wentSummary({ repositories: 1, projects: 0, members: 1, billing: null, protected: false }), "1 repository, 0 projects, 1 member"); |
| 9 | }); |
| 10 | |
| 11 | test("days left round up, and none once it is due", () => { |
| 12 | const now = Date.parse("2026-10-06T12:00:00Z"); |
| 13 | assert.equal(daysLeft("2026-11-05T12:00:00Z", now), 30); |
| 14 | assert.equal(daysLeft("2026-10-06T13:00:00Z", now), 1); |
| 15 | assert.equal(daysLeft("2026-10-06T12:00:00Z", now), 0); |
| 16 | assert.equal(daysLeft("2026-10-01T00:00:00Z", now), 0); |
| 17 | assert.equal(daysLeft("not a date", now), 0); |
| 18 | }); |
| 19 | |
| 20 | test("a purge is confirmed by the slug alone", () => { |
| 21 | assert.ok(confirmsPurge("acme", " Acme ")); |
| 22 | assert.ok(!confirmsPurge("acme", "")); |
| 23 | assert.ok(!confirmsPurge("acme", "acme-inc")); |
| 24 | }); |