Skip to content

Commit e5791fc

Browse files
authored
Merge pull request #312 from Citrinin/add-header-tests
[add]: a unit test for header component
2 parents e32acb6 + d333ce3 commit e5791fc

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Header renders correctly 1`] = `
4+
<div
5+
className="shadow flex items-center justify-center flex-col mb-2 py-2"
6+
>
7+
<a
8+
href="/"
9+
>
10+
<h1
11+
className="text-base font-bold font-title sm:text-2xl font-medium text-blue-800 flex justify-center items-center flex-col"
12+
>
13+
<img
14+
alt="github profile markdown generator logo"
15+
className="w-12 h-12"
16+
src="test-file-stub"
17+
/>
18+
<div>
19+
heading
20+
</div>
21+
</h1>
22+
</a>
23+
<div
24+
className="flex justify-center items-center"
25+
>
26+
<a
27+
aria-label="Star rahuldkjain/github-profile-readme-generator on GitHub"
28+
className="mr-2"
29+
href="https://github.com/rahuldkjain/github-profile-readme-generator"
30+
target="blank"
31+
>
32+
<div
33+
className="text-xxs sm:text-sm border-2 border-solid border-gray-900 bg-gray-100 flex items-center justify-center py-1 px-2"
34+
>
35+
<svg
36+
aria-hidden="true"
37+
className="px-1 w-6 star"
38+
dangerouslySetInnerHTML={
39+
Object {
40+
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M8 .25a.75.75 0 01.673.418l1.882 3.815 4.21.612a.75.75 0 01.416 1.279l-3.046 2.97.719 4.192a.75.75 0 01-1.088.791L8 12.347l-3.766 1.98a.75.75 0 01-1.088-.79l.72-4.194L.818 6.374a.75.75 0 01.416-1.28l4.21-.611L7.327.668A.75.75 0 018 .25zm0 2.445L6.615 5.5a.75.75 0 01-.564.41l-3.097.45 2.24 2.184a.75.75 0 01.216.664l-.528 3.084 2.769-1.456a.75.75 0 01.698 0l2.77 1.456-.53-3.084a.75.75 0 01.216-.664l2.24-2.183-3.096-.45a.75.75 0 01-.564-.41L8 2.694v.001z\\"></path>",
41+
}
42+
}
43+
fill="currentColor"
44+
height={16}
45+
role="img"
46+
style={
47+
Object {
48+
"display": "inline-block",
49+
"userSelect": "none",
50+
"verticalAlign": "text-bottom",
51+
}
52+
}
53+
viewBox="0 0 16 16"
54+
width={16}
55+
/>
56+
Star this repo
57+
<span
58+
className="github-count px-1 sm:px-2"
59+
>
60+
0
61+
</span>
62+
</div>
63+
</a>
64+
<a
65+
aria-label="Fork rahuldkjain/github-profile-readme-generator on GitHub"
66+
href="https://github.com/rahuldkjain/github-profile-readme-generator/fork"
67+
target="blank"
68+
>
69+
<div
70+
className="text-xxs sm:text-sm border-2 border-solid border-gray-900 bg-gray-100 flex items-center justify-center py-1 px-2"
71+
>
72+
<svg
73+
aria-hidden="true"
74+
className="px-1 w-6 fork"
75+
dangerouslySetInnerHTML={
76+
Object {
77+
"__html": "<path fill-rule=\\"evenodd\\" d=\\"M5 3.25a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm0 2.122a2.25 2.25 0 10-1.5 0v.878A2.25 2.25 0 005.75 8.5h1.5v2.128a2.251 2.251 0 101.5 0V8.5h1.5a2.25 2.25 0 002.25-2.25v-.878a2.25 2.25 0 10-1.5 0v.878a.75.75 0 01-.75.75h-4.5A.75.75 0 015 6.25v-.878zm3.75 7.378a.75.75 0 11-1.5 0 .75.75 0 011.5 0zm3-8.75a.75.75 0 100-1.5.75.75 0 000 1.5z\\"></path>",
78+
}
79+
}
80+
fill="currentColor"
81+
height={16}
82+
role="img"
83+
style={
84+
Object {
85+
"display": "inline-block",
86+
"userSelect": "none",
87+
"verticalAlign": "text-bottom",
88+
}
89+
}
90+
viewBox="0 0 16 16"
91+
width={16}
92+
/>
93+
Fork on GitHub
94+
<span
95+
className="github-count px-1 sm:px-2"
96+
>
97+
0
98+
</span>
99+
</div>
100+
</a>
101+
</div>
102+
</div>
103+
`;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from "react"
2+
import renderer from "react-test-renderer"
3+
4+
import Header from "../header"
5+
6+
describe("Header", () => {
7+
it("renders correctly", () => {
8+
const tree = renderer
9+
.create(<Header heading="heading" />)
10+
.toJSON()
11+
expect(tree).toMatchSnapshot()
12+
})
13+
})

0 commit comments

Comments
 (0)