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