| 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 | }); |