-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Heading.test.mjs
46 lines (41 loc) · 1.19 KB
/
Heading.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
45
46
// @ts-check
import React from "react";
import ReactDOMServer from "react-dom/server";
import assertSnapshot from "snapshot-assertion";
import Heading from "./Heading.mjs";
import assertBundleSize from "./test/assertBundleSize.mjs";
/**
* Adds `Heading` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add("`Heading` bundle size.", async () => {
await assertBundleSize(new URL("./Heading.mjs", import.meta.url), 450);
});
tests.add("`Heading` without props.", async () => {
await assertSnapshot(
ReactDOMServer.renderToStaticMarkup(
React.createElement(Heading, null, "Children")
),
new URL("./test/snapshots/Heading/without-props.html", import.meta.url)
);
});
tests.add("`Heading` with props.", async () => {
await assertSnapshot(
ReactDOMServer.renderToStaticMarkup(
React.createElement(
Heading,
{
level: 2,
size: 3,
className: "a",
id: "b",
["data-c"]: "d",
},
"Children"
)
),
new URL("./test/snapshots/Heading/with-props.html", import.meta.url)
);
});
};