Reference solution
The findings below are ordered by priority.
Findings
1. Every currency is converted as though it had two minor digits
Location: src/currency-display.ts:8
Dividing every amount by 100 is valid for USD only. A JPY value of 1,234 is displayed as roughly 12 yen instead of 1,234 yen, while 1,234 KWD minor units become about 12.34 dinars instead of 1.234. These are material price changes, not merely presentation differences.
Map each supported currency to its documented exponent and divide by 10 raised to that exponent before handing the major-unit value to Intl.NumberFormat.
2. The shopper's locale is ignored
Location: src/currency-display.ts:10
The formatter always uses en-US even though locale is a required input. Shoppers in other locales receive US grouping, decimal separators, sign conventions, and symbol placement rather than the requested localized representation.
Pass the supplied locale to Intl.NumberFormat and let the platform apply its locale data.
3. Refunds and credits lose their negative sign
Location: src/currency-display.ts:8
Math.abs turns every negative minor-unit amount positive. A refund such as -1,234 USD is displayed as a $12.34 charge-like value, reversing the financial meaning shown to the user.
Preserve the sign during minor-to-major conversion and allow the internationalization formatter to render it.
4. The test exercises only the one combination that fits the assumptions
Location: src/currency-display.test.ts:6-8
Positive USD in en-US has two minor digits and matches the hard-coded locale, so the test passes despite all three production defects. It gives no coverage to alternate exponents, locale punctuation, or signed values.
Add representative JPY and KWD cases, at least one non-US locale, and a negative amount. Derive expected strings from the stated locale behavior rather than weakening assertions to substring checks.
Reasonable non-findings
- Using
Intl.NumberFormat with style: "currency" is appropriate.
- The currency code is passed through to the formatter correctly.
- The helper may rely on the caller guarantees for safe integers and supported locale identifiers.