-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHydrationTimeStampContext.test.mjs
42 lines (34 loc) · 1.07 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
// @ts-check
import { strictEqual } from "node:assert";
import React from "react";
import HydrationTimeStampContext from "./HydrationTimeStampContext.mjs";
import assertBundleSize from "./test/assertBundleSize.mjs";
import createReactTestRenderer from "./test/createReactTestRenderer.mjs";
/**
* Adds `HydrationTimeStampContext` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add("`HydrationTimeStampContext` bundle size.", async () => {
await assertBundleSize(
new URL("./HydrationTimeStampContext.mjs", import.meta.url),
150
);
});
tests.add("`HydrationTimeStampContext` 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);
});
};