Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcsonline committed Jun 26, 2024
1 parent f84b0ab commit babddb5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions __tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,24 @@ describe('i18n', () => {
})

describe('formatNumber', () => {
const spacer = String.fromCharCode(160)

it('formats percentages', () => {
expect(i18n.formatNumber(0.2, 'percent')).toBe('20%')
expect(i18n.formatNumber(0.2, 'percent')).toBe('20' + spacer + '%')
})
it('formats the correct currency without locale code', () => {
expect(i18n.formatNumber(1500, 'currency', 'GBP')).toBe('£1,500.00')
expect(i18n.formatNumber(1500, 'currency', 'GBP')).toBe('1500,00' + spacer + 'GBP')
})
it('formats number with just a number', () => {
expect(i18n.formatNumber(1500)).toBe('1,500')
expect(i18n.formatNumber(1500)).toBe('1500')
})
it('formats currency with setLocale of language and country', () => {
i18n.setLocale('de-DE')
const spacer = String.fromCharCode(160)
expect(i18n.formatNumber(123456.789, 'currency', 'EUR')).toBe('123.456,79' + spacer + '€')
})
it('formats currency with setLocale of just country', () => {
i18n.setLocale('GB')
expect(i18n.formatNumber(1500, 'currency', 'GBP')).toBe('£1,500.00')
expect(i18n.formatNumber(1500, 'currency', 'GBP')).toBe('1500,00' + spacer + 'GBP')
})
it('formats currency with setLocale of just language', () => {
i18n.setLocale('en')
Expand Down

0 comments on commit babddb5

Please sign in to comment.