-
Notifications
You must be signed in to change notification settings - Fork 13
fix(amount): added bigInt and hideCurrency support in amount component #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,14 +2,18 @@ import { type ComponentProps } from 'react'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface AmountProps extends ComponentProps<'span'> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * The monetary value to display | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * For large numbers (> 2^53), pass the value as string to maintain precision | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \ * The monetary value to display. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * For exact precision beyond 2^53, pass either: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - a `string` — supports decimals (e.g. "1299" or "12.99") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * - a `bigint` — integer-only; treated as already in major units, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * `valueInMinorUnits` is ignored when value is a bigint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @default 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @example | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * valueInMinorUnits=true: 1299 => "$12.99" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * valueInMinorUnits=false: 12.99 => "$12.99" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * bigint: 1299n => "$1,299.00" (always major units) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value: number | string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value: number | string | bigint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * ISO 4217 currency code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -66,6 +70,16 @@ export interface AmountProps extends ComponentProps<'span'> { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @default true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| groupDigits?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Render the formatted number without a currency symbol, code, or name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Locale-driven separators, grouping, and fraction digits are preserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * When true, `currencyDisplay` is ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @default false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @example | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * <Amount value={1299} hideCurrency /> => "12.99" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hideCurrency?: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -151,6 +165,7 @@ export const Amount = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| maximumFractionDigits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| groupDigits = true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| valueInMinorUnits = true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hideCurrency = false, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...props | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: AmountProps) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -160,7 +175,7 @@ export const Amount = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Warning: The number ${value} exceeds JavaScript's safe integer limit (${Number.MAX_SAFE_INTEGER}). ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'For large numbers, pass the value as a string to maintain precision.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'For large numbers, pass the value as a bigint or string to maintain precision.' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -171,37 +186,63 @@ export const Amount = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const decimals = getCurrencyDecimals(validCurrency); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Handle minor units - use string manipulation for strings and Math.pow for numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const baseValue = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| valueInMinorUnits && decimals > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? typeof value === 'string' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? value.slice(0, -decimals) + '.' + value.slice(-decimals) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : value / Math.pow(10, decimals) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Remove decimals if hideDecimals is true - handle string and number separately | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Note: Not all numbers passed is converted to string as methods like Math.trunc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // or toString cannot handle large numbers thus, we need to handle it separately (large numbers passed in value throws console warning). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const finalBaseValue = hideDecimals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? typeof baseValue === 'string' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? baseValue.split('.')[0] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Math.trunc(baseValue) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : baseValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const formattedValue = new Intl.NumberFormat(locale, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: 'currency' as const, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currency: validCurrency.toUpperCase(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currencyDisplay, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Convert minor → major units. Three input shapes: bigint, string, number. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // bigint is always treated as already in major units (it cannot represent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // fractions), so `valueInMinorUnits` is ignored for bigint. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let baseValue: number | string | bigint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof value === 'bigint') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseValue = value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (valueInMinorUnits && decimals > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof value === 'string') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isNegative = value.startsWith('-'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const digits = isNegative ? value.slice(1) : value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const padded = digits.padStart(decimals + 1, '0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const major = padded.slice(0, -decimals); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const minor = padded.slice(-decimals); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseValue = `${isNegative ? '-' : ''}${major}.${minor}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseValue = value / Math.pow(10, decimals); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseValue = value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Remove decimals when hideDecimals is true. bigint has no decimals, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // it's a no-op there. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let finalBaseValue: number | string | bigint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!hideDecimals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finalBaseValue = baseValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (typeof baseValue === 'bigint') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finalBaseValue = baseValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (typeof baseValue === 'string') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finalBaseValue = baseValue.split('.')[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| finalBaseValue = Math.trunc(baseValue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const formatOptions: Intl.NumberFormatOptions = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| minimumFractionDigits: hideDecimals ? 0 : minimumFractionDigits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| maximumFractionDigits: hideDecimals ? 0 : maximumFractionDigits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useGrouping: groupDigits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useGrouping: groupDigits, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(hideCurrency | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? { style: 'decimal' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style: 'currency', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currency: validCurrency.toUpperCase(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currencyDisplay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+223
to
+234
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The spread The test suite covers only 🛠️ Proposed fix — propagate `decimals` as default in the `hideCurrency` branch- const formatOptions: Intl.NumberFormatOptions = {
- minimumFractionDigits: hideDecimals ? 0 : minimumFractionDigits,
- maximumFractionDigits: hideDecimals ? 0 : maximumFractionDigits,
- useGrouping: groupDigits,
- ...(hideCurrency
- ? { style: 'decimal' }
- : {
- style: 'currency',
- currency: validCurrency.toUpperCase(),
- currencyDisplay
- })
- };
+ const formatOptions: Intl.NumberFormatOptions = {
+ useGrouping: groupDigits,
+ ...(hideCurrency
+ ? {
+ style: 'decimal',
+ minimumFractionDigits: hideDecimals ? 0 : (minimumFractionDigits ?? decimals),
+ maximumFractionDigits: hideDecimals ? 0 : (maximumFractionDigits ?? decimals),
+ }
+ : {
+ style: 'currency',
+ currency: validCurrency.toUpperCase(),
+ currencyDisplay,
+ minimumFractionDigits: hideDecimals ? 0 : minimumFractionDigits,
+ maximumFractionDigits: hideDecimals ? 0 : maximumFractionDigits,
+ })
+ };After this fix, also update the bigint - expect(screen.getByText('1,299')).toBeInTheDocument();
+ expect(screen.getByText('1,299.00')).toBeInTheDocument();And add a coverage case for round amounts: it('preserves currency fraction digits for round amounts', () => {
render(<Amount value={1200} hideCurrency />);
expect(screen.getByText('12.00')).toBeInTheDocument();
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const formattedValue = new Intl.NumberFormat( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| locale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formatOptions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error TS lib types omit `string` from format() params, but Intl.NumberFormat accepts numeric strings at runtime — needed for large values that would lose precision as `number`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } as Intl.NumberFormatOptions).format(finalBaseValue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).format(finalBaseValue); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
239
to
+240
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n packages/raystack/components/amount/amount.tsx | sed -n '230,250p'Repository: raystack/apsara Length of output: 860 🏁 Script executed: find . -name "package.json" -type f | head -5Repository: raystack/apsara Length of output: 206 🏁 Script executed: cat package.json | jq '.browserslist, .engines, .targets' 2>/dev/null || cat package.json | grep -A 5 -E '(browserslist|engines|targets)'Repository: raystack/apsara Length of output: 90 🏁 Script executed: cat packages/raystack/package.json | jq '.browserslist, .engines, .targets, .exports, .main' 2>/dev/null || cat packages/raystack/package.jsonRepository: raystack/apsara Length of output: 691 🌐 Web query:
💡 Result: Intl.NumberFormat V3 refers to the ECMA-402 proposal adding advanced features like roundingPriority ("auto", "morePrecision", "lessPrecision"), roundingMode, and enhanced string precision control via minimumSignificantDigits/maximumSignificantDigits (1-21 range) in conjunction with fractionDigits, resolving conflicts via roundingPriority. These enable precise string-based number formatting without floating-point loss, key for ES2023 Intl updates.[1][2][3][4] Browser support timeline (full V3 features like roundingMode, roundingPriority): - Chrome/Edge: 106+ (Oct 2022)[1][5][6] - Firefox: 93 (initial), full 116+ (2023)[1][6] - Safari: 15.4+ (Mar 2022)[1][6] By 2026-05-07, universally supported in modern browsers (global usage >98%). Basic significantDigits supported earlier (Chrome 24+, Firefox 29+, Safari 10+).[7] Example for string precision: new Intl.NumberFormat('en-US', { maximumSignificantDigits: 3, roundingPriority: 'lessPrecision' }).format('1234.56789'); // "1,230" (respects both sig/maxFraction via priority)[3][4] Official spec in ECMAScript 2023 Intl API (10.0).[8] Citations:
🏁 Script executed: grep -r "Amount" packages/raystack/package.json | head -10Repository: raystack/apsara Length of output: 41 🏁 Script executed: grep -B5 "finalBaseValue" packages/raystack/components/amount/amount.tsx | head -20Repository: raystack/apsara Length of output: 826 🏁 Script executed: cat packages/raystack/README.md 2>/dev/null | head -50 || echo "No README found"Repository: raystack/apsara Length of output: 1785 🏁 Script executed: find . -maxdepth 2 -name ".browserslistrc" -o -name "tsconfig.json" -o -name "tsconfig.build.json" -o -name "vite.config.ts" -o -name "tsup.config.ts" 2>/dev/null | head -10Repository: raystack/apsara Length of output: 41 🏁 Script executed: cat tsconfig.json | jq '.compilerOptions.lib, .compilerOptions.target, .compilerOptions.useDefineForClassFields' 2>/dev/null || grep -A 5 '"target"' tsconfig.jsonRepository: raystack/apsara Length of output: 105 🏁 Script executed: find packages/raystack -name "tsconfig.json" -o -name "vite.config.ts" -o -name "tsup.config.ts" 2>/dev/nullRepository: raystack/apsara Length of output: 91 🏁 Script executed: find . -maxdepth 3 -name ".browserslistrc" 2>/dev/nullRepository: raystack/apsara Length of output: 41 🏁 Script executed: cat packages/raystack/tsconfig.json 2>/dev/null || echo "Not found"Repository: raystack/apsara Length of output: 568 🏁 Script executed: cat packages/tools-config/tsconfig/react.json 2>/dev/null || find . -path "*tools-config*" -name "*.json" -type f | head -10Repository: raystack/apsara Length of output: 310 🏁 Script executed: find . -maxdepth 2 -name "*.config.ts" -o -name "*.config.js" -type f | grep -E "(vite|tsup|esbuild|webpack)" | head -5Repository: raystack/apsara Length of output: 41 🏁 Script executed: cat packages/raystack/package.json | jq '.browserslist' 2>/dev/nullRepository: raystack/apsara Length of output: 64 🏁 Script executed: cat packages/tools-config/tsconfig/base.json 2>/dev/null | head -30Repository: raystack/apsara Length of output: 580 🌐 Web query:
💡 Result: Intl.NumberFormat supports string parameters for the locales argument (a BCP 47 language tag string or array of strings) and accepts an options object as the second parameter. This API is not part of ES5 (ECMA-262 5th edition, 2009), which has no Intl object or NumberFormat.[1][2] It was first specified in ECMA-402 1st edition (December 2012), the ECMAScript Internationalization API Specification, with the constructor defined as Intl.NumberFormat([locales [, options ]]), where locales can be a string.[3][4][5][6] ECMA-402 1st edition aligned with ES6 (ECMA-262 6th edition, June 2015) development timeline, but the core API (including string locales support) was present from the initial 2012 spec and unchanged in basic constructor signature across editions.[7][8][9] Browser support began pre-ES6: Chrome 24 (2013), Firefox 29 (2014), Safari 10 (2016).[10][11] No evidence of string parameter support in ES5; Intl was added via ECMA-402.[12][13] Citations:
Verify minimum browser targets for The code passes strings to Confirm that the minimum supported browsers include full Intl.NumberFormat V3 string-precision support, or add a feature-detection guard: const supportsStringFormat = new Intl.NumberFormat('und').format('11111111111111111112').indexOf('2') !== -1;🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return <span {...props}>{formattedValue}</span>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error('Error formatting amount:', error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return <span {...props}>{value}</span>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return <span {...props}>{String(value)}</span>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hideCurrencytest suite covers only non-round amountsAll four
hideCurrencytests usevalue={1299}(USD → 12.99) or a zero-decimal currency (JPY). None exercise a round amount likevalue={1200}(USD → 12.00) where the fraction digit discrepancy from the major issue above would manifest. The coverage gap means the bug is undetected by the test suite even though the docs promise "fraction digits are preserved."These tests will need to be updated once the fix proposed in the
amount.tsxcomment is applied.🤖 Prompt for AI Agents