Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Billing: credits with a kind and expiry, discounts instead of comped, and safer charging | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { fullDiscount, percentOff, termsLabel } from "./terms.ts"; | |
| 5 | ||
| 6 | test("terms read as a discount; comped from before discounts is 100%", () => { | |
| 7 | assert.equal(percentOff({ kind: "comped", discountPercent: 0 }), 100); | |
| 8 | assert.equal(percentOff({ kind: "custom", discountPercent: 30 }), 30); | |
| 9 | assert.equal(percentOff({ kind: "standard", discountPercent: 30 }), 0); | |
| 10 | assert.ok(fullDiscount({ kind: "custom", discountPercent: 100 })); | |
| 11 | assert.ok(!fullDiscount({ kind: "custom", discountPercent: 99 })); | |
| 12 | assert.equal(termsLabel({ kind: "custom", discountPercent: 100 }), "100% discount"); | |
| 13 | assert.equal(termsLabel({ kind: "comped", discountPercent: 0 }), "100% discount"); | |
| 14 | assert.equal(termsLabel({ kind: "custom", discountPercent: 30 }), "30% off"); | |
| 15 | assert.equal(termsLabel({ kind: "custom", discountPercent: 0 }), "Custom limit"); | |
| 16 | assert.equal(termsLabel({ kind: "standard", discountPercent: 0 }), "Standard"); | |
| 17 | }); |