Skip to content

Commit b4db149

Browse files
committed
tests(constants): add tests for constants
1 parent 9b53815 commit b4db149

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/constants.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as constants from "../src/constants/mod.ts";
2+
import { describe, it } from "jsr:@std/testing@1/bdd";
3+
import { expect } from "jsr:@std/expect@1";
4+
5+
const cases = {
6+
Math: [
7+
"E",
8+
"LN2",
9+
"LN10",
10+
"LOG2E",
11+
"LOG10E",
12+
"PI",
13+
"SQRT1_2",
14+
"SQRT2",
15+
],
16+
Number: [
17+
"EPSILON",
18+
"MAX_SAFE_INTEGER",
19+
"MIN_SAFE_INTEGER",
20+
"NEGATIVE_INFINITY",
21+
"POSITIVE_INFINITY",
22+
"NaN",
23+
"MAX_VALUE",
24+
"MIN_VALUE",
25+
],
26+
} as const;
27+
28+
for (const kind of Object.keys(cases) as (keyof typeof cases)[]) {
29+
const keys = cases[kind];
30+
for (const key of keys) {
31+
describe(key, () => {
32+
const value = constants[key];
33+
const parent = globalThis[kind];
34+
const expected = parent[key as keyof typeof parent];
35+
it(`is equal to ${kind}.${key}`, () => {
36+
expect(value).toBe(expected);
37+
});
38+
});
39+
}
40+
}

0 commit comments

Comments
 (0)