Skip to content

Commit 2bb2650

Browse files
committed
Create snapshot for Rocket to test
1 parent 8095814 commit 2bb2650

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

src/tests/Rocket.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { Provider } from 'react-redux';
3+
import configureStore from 'redux-mock-store';
4+
import renderer from 'react-test-renderer';
5+
import Rocket from '../components/Rocket';
6+
7+
// Create a mock store with the state you want to use in the test
8+
const mockStore = configureStore([]);
9+
10+
test('Rocket component renders correctly', () => {
11+
const mockRocket = {
12+
id: '5e9d0d95eda69955f709d1eb',
13+
name: 'Falcon 1',
14+
description: 'Description 1',
15+
flickr_images: ['https://imgur.com/DaCfMsj.jpg'],
16+
reserved: false,
17+
};
18+
19+
const store = mockStore({});
20+
21+
const tree = renderer.create(
22+
<Provider store={store}>
23+
<Rocket rocket={mockRocket} />
24+
</Provider>,
25+
).toJSON();
26+
expect(tree).toMatchSnapshot();
27+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Rocket component renders correctly 1`] = `
4+
<li
5+
className="rocket"
6+
>
7+
<img
8+
alt="Rocket Falcon 1"
9+
className="rocket-image"
10+
src="https://imgur.com/DaCfMsj.jpg"
11+
/>
12+
<div
13+
className="rocket-details"
14+
>
15+
<h3
16+
className="rocket-title"
17+
>
18+
Falcon 1
19+
</h3>
20+
<div>
21+
<p
22+
className="rocket-description"
23+
>
24+
Description 1
25+
</p>
26+
</div>
27+
<button
28+
className="reserve-button"
29+
onClick={[Function]}
30+
type="submit"
31+
>
32+
Reserve Rocket
33+
</button>
34+
</div>
35+
</li>
36+
`;

0 commit comments

Comments
 (0)