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