|
| 1 | +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair |
| 2 | +/* eslint-disable @typescript-eslint/no-magic-numbers */ |
1 | 3 | import assert from 'node:assert';
|
2 | 4 | import { describe, it } from 'node:test';
|
3 | 5 | import stringToNumeric from '../index.js';
|
4 | 6 | await describe('string-to-numeric', async () => {
|
5 |
| - await it('Converts simple strings into numeric values', async () => { |
| 7 | + await it('Converts simple strings into numeric values', () => { |
6 | 8 | assert.strictEqual(stringToNumeric('33'), 33);
|
7 | 9 | assert.strictEqual(stringToNumeric('1.1'), 1.1);
|
8 | 10 | });
|
9 |
| - await it('Converts strings with thousands separators into numeric values', async () => { |
| 11 | + await it('Converts strings with thousands separators into numeric values', () => { |
10 | 12 | assert.strictEqual(stringToNumeric('1,234.1'), 1234.1);
|
11 | 13 | assert.strictEqual(stringToNumeric('1.234,1', {
|
12 | 14 | decimalSeparator: ','
|
13 | 15 | }), 1234.1);
|
14 | 16 | });
|
15 |
| - await it('Converts strings with leading decimal into numeric values', async () => { |
| 17 | + await it('Converts strings with leading decimal into numeric values', () => { |
16 | 18 | assert.strictEqual(stringToNumeric('.2'), 0.2);
|
17 | 19 | assert.strictEqual(stringToNumeric(',3', { decimalSeparator: ',' }), 0.3);
|
18 | 20 | });
|
19 |
| - await it('Converts strings with leading units into numeric values', async () => { |
| 21 | + await it('Converts strings with leading units into numeric values', () => { |
20 | 22 | assert.strictEqual(stringToNumeric('$2'), 2);
|
21 | 23 | assert.strictEqual(stringToNumeric('# 456'), 456);
|
22 | 24 | assert.strictEqual(stringToNumeric('No. 812'), 812);
|
23 | 25 | assert.strictEqual(stringToNumeric('$58,742.200'), 58_742.2);
|
24 | 26 | });
|
25 |
| - await it('Converts strings with trailing units into numeric values', async () => { |
| 27 | + await it('Converts strings with trailing units into numeric values', () => { |
26 | 28 | assert.strictEqual(stringToNumeric('99 red balloons'), 99);
|
27 | 29 | assert.strictEqual(stringToNumeric('100mm'), 100);
|
28 | 30 | });
|
29 |
| - await it('Converts strings with negative indicators into numeric values', async () => { |
| 31 | + await it('Converts strings with negative indicators into numeric values', () => { |
30 | 32 | assert.strictEqual(stringToNumeric('-2'), -2);
|
31 | 33 | assert.strictEqual(stringToNumeric('(4.2)'), -4.2);
|
32 | 34 | assert.strictEqual(stringToNumeric('($4.000)'), -4);
|
33 | 35 | });
|
34 |
| - await it('Handles errors', async () => { |
| 36 | + await it('Handles errors', () => { |
35 | 37 | // eslint-disable-next-line unicorn/no-useless-undefined, @typescript-eslint/no-confusing-void-expression
|
36 | 38 | assert.strictEqual(stringToNumeric(undefined), undefined);
|
37 | 39 | // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression, unicorn/no-null
|
|
0 commit comments