Skip to content

Commit 515eea9

Browse files
committed
Test Profile using Jest snapshot
1 parent 7bfd17a commit 515eea9

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

src/tests/ProfileComponent.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import renderer from 'react-test-renderer';
3+
import ProfileComponent from '../components/Profile';
4+
5+
// Mock the child components to avoid actual rendering
6+
jest.mock('../components/JoinedMissions', () => 'JoinedMissions');
7+
jest.mock('../components/ReservedRockets', () => 'ReservedRockets');
8+
jest.mock('../components/ReservedDragons', () => 'ReservedDragons');
9+
10+
describe('ProfileComponent', () => {
11+
it('renders correctly', () => {
12+
const component = renderer.create(<ProfileComponent />);
13+
expect(component.toJSON()).toMatchSnapshot();
14+
});
15+
});
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`ProfileComponent renders correctly 1`] = `
4+
<div
5+
className="container"
6+
>
7+
<div
8+
className="profile-table-container"
9+
>
10+
<table
11+
className="profile-table"
12+
>
13+
<thead>
14+
<tr>
15+
<th>
16+
My Missions
17+
</th>
18+
</tr>
19+
</thead>
20+
<tbody>
21+
<tr>
22+
<td>
23+
<JoinedMissions />
24+
</td>
25+
</tr>
26+
</tbody>
27+
</table>
28+
<table
29+
className="profile-table"
30+
>
31+
<thead>
32+
<tr>
33+
<th>
34+
My Rockets
35+
</th>
36+
</tr>
37+
</thead>
38+
<tbody>
39+
<tr>
40+
<td>
41+
<ReservedRockets />
42+
</td>
43+
</tr>
44+
</tbody>
45+
</table>
46+
<table
47+
className="profile-table"
48+
>
49+
<thead>
50+
<tr>
51+
<th>
52+
My Dragons
53+
</th>
54+
</tr>
55+
</thead>
56+
<tbody>
57+
<tr>
58+
<td>
59+
<ReservedDragons />
60+
</td>
61+
</tr>
62+
</tbody>
63+
</table>
64+
</div>
65+
</div>
66+
`;

0 commit comments

Comments
 (0)