diff --git a/libs/common/src/lib/helper.spec.ts b/libs/common/src/lib/helper.spec.ts index abac8acd57..e618dd698c 100644 --- a/libs/common/src/lib/helper.spec.ts +++ b/libs/common/src/lib/helper.spec.ts @@ -11,6 +11,10 @@ describe('Helper', () => { expect(extractNumberFromString({ value: '999.99' })).toEqual(999.99); }); + it('Get negative decimal number', () => { + expect(extractNumberFromString({ value: '-999.99' })).toEqual(-999.99); + }); + it('Get decimal number (with spaces)', () => { expect(extractNumberFromString({ value: ' 999.99 ' })).toEqual(999.99); }); @@ -19,6 +23,12 @@ describe('Helper', () => { expect(extractNumberFromString({ value: '999.99 CHF' })).toEqual(999.99); }); + it('Get negative decimal number (with currency)', () => { + expect(extractNumberFromString({ value: '-999.99 CHF' })).toEqual( + -999.99 + ); + }); + it('Get decimal number (comma notation)', () => { expect( extractNumberFromString({ locale: 'de-DE', value: '999,99' }) @@ -37,28 +47,18 @@ describe('Helper', () => { ).toEqual(99999.99); }); - it('Get decimal number (comma notation) for locale where currency is not grouped by default', () => { - expect( - extractNumberFromString({ locale: 'es-ES', value: '999,99' }) - ).toEqual(999.99); - }); - - it('Get negative decimal number', () => { - expect(extractNumberFromString({ value: '-999.99' })).toEqual(-999.99); - }); - - it('Get negative decimal number (with currency)', () => { - expect(extractNumberFromString({ value: '-999.99 CHF' })).toEqual( - -999.99 - ); - }); - it('Get negative decimal number with group (comma notation)', () => { expect( extractNumberFromString({ locale: 'de-DE', value: '-99.999,99' }) ).toEqual(-99999.99); }); + it('Get decimal number (comma notation) for locale where currency is not grouped by default', () => { + expect( + extractNumberFromString({ locale: 'es-ES', value: '999,99' }) + ).toEqual(999.99); + }); + it('Not a number', () => { expect(extractNumberFromString({ value: 'X' })).toEqual(NaN); });