Skip to content

Commit a9de2e6

Browse files
Ashley BibizadehAshley Bibizadeh
authored andcommitted
new tests for connected component app.js
1 parent 853a310 commit a9de2e6

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"axios": "^0.18.0",
77
"node-sass": "^4.11.0",
88
"prop-types": "^15.6.2",
9-
"react": "^16.7.0",
9+
"react": "^16.8.6",
1010
"react-dom": "^16.7.0",
11-
"react-redux": "^6.0.0",
11+
"react-redux": "^7.0.0-beta.0",
1212
"react-scripts": "2.1.3",
1313
"redux": "^4.0.1",
1414
"redux-thunk": "^2.3.0"

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class App extends Component {
3838
}
3939

4040
return (
41-
<div className="App">
41+
<div className="App" data-test="appComponent">
4242
<Header />
4343
<section className="main">
4444
<Headline header="Posts" desc="Click the button to render posts!" tempArr={tempArr} />

src/App.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import App from './App';
2+
import { shallow } from 'enzyme';
3+
import { findByTestAtrr, testStore } from './../Utils';
4+
import React from 'react';
5+
6+
const setUp = (initialState={}) => {
7+
const store = testStore(initialState);
8+
const wrapper = shallow(<App store={store} />).childAt(0).dive();
9+
return wrapper;
10+
};
11+
12+
describe('App Component', () => {
13+
14+
let wrapper;
15+
beforeEach(() => {
16+
const initialState = {
17+
posts: [{
18+
title: 'Example title 1',
19+
body: 'Some text'
20+
}, {
21+
title: 'Example title 2',
22+
body: 'Some text'
23+
}, {
24+
title: 'Example title 3',
25+
body: 'Some text'
26+
}]
27+
}
28+
wrapper = setUp(initialState);
29+
});
30+
31+
it('Should render without errors', () => {
32+
const component = findByTestAtrr(wrapper, 'appComponent');
33+
expect(component.length).toBe(1);
34+
});
35+
36+
37+
});

0 commit comments

Comments
 (0)