From babddb519232205decdceabd9c8c146b56ca3437 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Wed, 26 Jun 2024 09:20:10 +0200 Subject: [PATCH] Fix tests --- __tests__/index.spec.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/__tests__/index.spec.ts b/__tests__/index.spec.ts index a1d5c80..67fc803 100644 --- a/__tests__/index.spec.ts +++ b/__tests__/index.spec.ts @@ -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')