-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcjsDefaultImport.test.mjs
40 lines (31 loc) · 1.06 KB
/
cjsDefaultImport.test.mjs
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
// @ts-check
import { deepStrictEqual, strictEqual } from "node:assert";
import { describe, it } from "node:test";
import cjsDefaultImport from "./cjsDefaultImport.mjs";
import assertBundleSize from "./test/assertBundleSize.mjs";
describe("Function `cjsDefaultImport`.", { concurrency: true }, () => {
it("Bundle size.", async () => {
await assertBundleSize(
new URL("./cjsDefaultImport.mjs", import.meta.url),
120,
);
});
describe("Argument 1 `value`.", { concurrency: true }, () => {
it("Non object.", () => {
const value = false;
strictEqual(cjsDefaultImport(value), value);
});
describe("Object.", { concurrency: true }, () => {
it("Property `default` absent.", () => {
const value = Object.freeze({ a: 1 });
deepStrictEqual(cjsDefaultImport(value), value);
});
it("Property `default` present.", () => {
const value = Object.freeze({
default: Object.freeze({ a: 1 }),
});
deepStrictEqual(cjsDefaultImport(value), value.default);
});
});
});
});