-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
LoadingContext.test.mjs
41 lines (32 loc) · 997 Bytes
/
LoadingContext.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
41
// @ts-check
import { strictEqual } from "node:assert";
import { describe, it } from "node:test";
import React from "react";
import Loading from "./Loading.mjs";
import LoadingContext from "./LoadingContext.mjs";
import assertBundleSize from "./test/assertBundleSize.mjs";
import createReactTestRenderer from "./test/createReactTestRenderer.mjs";
describe("React context `LoadingContext`.", { concurrency: true }, () => {
it("Bundle size.", async () => {
await assertBundleSize(
new URL("./LoadingContext.mjs", import.meta.url),
120,
);
});
it("Used as a React context.", () => {
let contextValue;
function TestComponent() {
contextValue = React.useContext(LoadingContext);
return null;
}
const value = new Loading();
createReactTestRenderer(
React.createElement(
LoadingContext.Provider,
{ value },
React.createElement(TestComponent),
),
);
strictEqual(contextValue, value);
});
});