-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.test.ts
49 lines (46 loc) 路 834 Bytes
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { test, expect } from "vitest";
import { generateCleanNumber, filterNaNfromNumber } from "./index";
const scenarios = [
{
input: "12^~",
output: 12,
},
{
input: 13,
output: 13,
},
{
input: "1^2",
output: 12,
},
{
input: 14,
output: 14,
},
{
input: "14.1",
output: 14.1,
},
{
input: 14.1,
output: 14.1,
},
{
input: "14.1~",
output: 14.1,
},
{
input: "14.^1",
output: 14.1,
},
];
scenarios.forEach(function testScenario(scenario) {
test(`test generateCleanNumber`, () => {
const result = generateCleanNumber(scenario.input);
expect(result).toBe(scenario.output);
});
test(`test filterNaNfromNumber`, () => {
const result = filterNaNfromNumber(scenario.input);
expect(result).toBe(scenario.output);
});
});