Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions test/parseValue-excel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,35 @@
expect(parseBool('HAMIS', { locale: 'hu' }), 'hu: HAMIS').toEqual({ v: false });
});

test('parseNumber accepts spaces after a number', () => {
expect(parseNumber('5 ')?.v).toBe(5);

Check failure on line 135 in test/parseValue-excel.spec.ts

View workflow job for this annotation

GitHub Actions / test

test/parseValue-excel.spec.ts > parseValue: EXCEL mode > parseNumber accepts spaces after a number

AssertionError: expected undefined to be 5 // Object.is equality - Expected: 5 + Received: undefined ❯ test/parseValue-excel.spec.ts:135:34
expect(parseNumber(' 5 ')?.v).toBe(5);
expect(parseNumber('5 ')?.v).toBe(5);
expect(parseNumber('1.5 ')?.v).toBe(1.5);
expect(parseNumber('1,000 ')?.v).toBe(1000);
expect(parseNumber('100 % ')?.v).toBe(1);
expect(parseNumber('$5 ')?.v).toBe(5);
expect(parseNumber('(5) ')?.v).toBe(-5);
});

test('parseNumber refuses other whitespace next to a number', () => {
for (const text of [
'5\u00a0',
'5\u202f',
'5\u00a0 ',
'5\u202f ',
'5 \u00a0',
'5\u00a0%',
'5\t',
'5\n',
'5\r',
'5 \t',
'\t5'
]) {
expect(parseNumber(text), JSON.stringify(text)).toBe(undefined);

Check failure on line 159 in test/parseValue-excel.spec.ts

View workflow job for this annotation

GitHub Actions / test

test/parseValue-excel.spec.ts > parseValue: EXCEL mode > parseNumber refuses other whitespace next to a number

AssertionError: "5 %": expected { v: 0.05, z: '0%' } to be undefined // Object.is equality - Expected: undefined + Received: { "v": 0.05, "z": "0%", } ❯ test/parseValue-excel.spec.ts:159:55
}
});

test('issue #71', () => {
expect(parseValue('2021/1-10')).toEqual({ v: 44206, z: 'm/d/yy' });
});
Expand Down
Loading