Skip to content

Commit b7e1913

Browse files
committed
add tests
1 parent 882a4a1 commit b7e1913

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/composer.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,45 @@ describe('n', () => {
659659
expect(n(0.99, { key: 'percent', fallbackWarn: false })).toEqual('99%')
660660
})
661661

662+
test('minimumFractionDigits, maximumFractionDigits', () => {
663+
const { n } = createComposer({
664+
locale: 'US',
665+
fallbackLocale: ['ja-JP'],
666+
numberFormats: {
667+
US: {
668+
currency: {
669+
style: 'currency',
670+
currency: 'USD',
671+
minimumFractionDigits: 0,
672+
maximumFractionDigits: 2
673+
},
674+
decimal: {
675+
style: 'decimal',
676+
currency: 'USD',
677+
minimumFractionDigits: 0,
678+
maximumFractionDigits: 2
679+
}
680+
},
681+
'ja-JP': {
682+
currency: {
683+
style: 'currency',
684+
currency: 'JPY' /*, currencyDisplay: 'symbol'*/
685+
},
686+
numeric: {
687+
style: 'decimal',
688+
useGrouping: false
689+
},
690+
percent: {
691+
style: 'percent',
692+
useGrouping: false
693+
}
694+
}
695+
}
696+
})
697+
expect(n(0.99, { key: 'currency', fallbackWarn: false })).toEqual('$0.99')
698+
expect(n(1.1111, { key: 'decimal', fallbackWarn: false })).toEqual('1.11')
699+
})
700+
662701
test('missing', () => {
663702
const { n } = createComposer({
664703
locale: 'en-US',

0 commit comments

Comments
 (0)