From 3667ffe77d53e52ed9e5c48fa3b1f02c5d9a1de7 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 31 Jul 2026 05:18:16 +0000 Subject: [PATCH] fix(test): align setup amount test with fractional-cent rejection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #59 made the numeric path of setupAmountUsd reject values finer than a cent, but left the assertion that 2.345 rounds to 2.35 — the exact behavior it removed. That assertion has failed on master ever since, so every PR opened since #59 shows a red test check. Assert the numeric path on a value it actually accepts, and add the regression coverage issue #54 asked for (1.234 and 0.004) that #59 described but never landed. Co-Authored-By: Claude Opus 5 (1M context) --- tests/coinpay-amount.test.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/coinpay-amount.test.mjs b/tests/coinpay-amount.test.mjs index f1bc97e..6b03827 100644 --- a/tests/coinpay-amount.test.mjs +++ b/tests/coinpay-amount.test.mjs @@ -6,7 +6,13 @@ import { setupAmountUsd } from "../lib/coinpay.ts"; test("setupAmountUsd accepts ordinary positive dollar amounts", () => { assert.equal(setupAmountUsd("1.00"), 1); assert.equal(setupAmountUsd(" 1,234.56 "), 1234.56); - assert.equal(setupAmountUsd(2.345), 2.35); + assert.equal(setupAmountUsd(2.35), 2.35); +}); + +test("setupAmountUsd rejects numbers finer than a cent", () => { + assert.throws(() => setupAmountUsd(2.345), /fractional cents/); + assert.throws(() => setupAmountUsd(1.234), /fractional cents/); + assert.throws(() => setupAmountUsd(0.004), /fractional cents/); }); test("setupAmountUsd rejects malformed or unsafe payment amounts", () => {