Skip to content

Commit 57725dc

Browse files
committed
Added tests in the app. Added Jest dev and peer packages.
1 parent 74949f5 commit 57725dc

File tree

6 files changed

+119
-509
lines changed

6 files changed

+119
-509
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
## Webpack4 - React16.7 Templater App
22

33

4+
# 1.7.1
5+
* Added Jest dev and peer packages.
6+
* Fixed Jest testing environment.
7+
* Minor improvements.
8+
49
# 1.4.0
510
* Added Tests example in the App.
611
* Fixed animation in App Component.

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ module.exports = {
1818
'^.+\\.jsx?$': 'babel-jest',
1919
'^.+\\.tsx?$': 'ts-jest'
2020
},
21-
setupFiles: ['<rootDir>/setupTests.js', '<rootDir>/node_modules/whatwg-fetch/fetch.js'],
21+
setupFiles: ['<rootDir>/setupTests.js'],
2222
snapshotSerializers: ['enzyme-to-json/serializer']
2323
};

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
"eslint-plugin-react": "^7.12.1",
115115
"eslint-plugin-react-hooks": "^0.0.0",
116116
"husky": "^1.3.1",
117+
"identity-obj-proxy": "^3.0.0",
117118
"jest": "^23.6.0",
118119
"jest-cli": "^23.6.0",
119120
"jsonlint": "^1.6.3",
@@ -160,6 +161,8 @@
160161
"@babel/preset-stage-3": "^7.0.0",
161162
"@babel/preset-typescript": "^7.1.0",
162163
"awesome-typescript-loader": "^5.2.1",
164+
"babel-core": "^7.0.0-bridge.0",
165+
"babel-jest": "^23.6.0",
163166
"babel-loader": "^8.0.5",
164167
"babel-plugin-transform-runtime": "^6.23.0",
165168
"babel-polyfill": "^6.26.0",
@@ -169,6 +172,7 @@
169172
"connect-history-api-fallback": "^1.5.0",
170173
"connected-react-router": "^6.1.0",
171174
"debug": "^4.1.1",
175+
"enzyme-adapter-react-16": "^1.7.1",
172176
"eslint-loader": "^2.1.1",
173177
"exports-loader": "^0.7.0",
174178
"history": "^4.7.2",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Body Component Test /> should render basic Body Component with an image 1`] = `
4+
<Body
5+
imageToShow={3}
6+
switchImage={[Function]}
7+
>
8+
<div
9+
className="body"
10+
>
11+
<button
12+
className="button"
13+
onClick={[Function]}
14+
type="button"
15+
>
16+
<TransitionGroup
17+
childFactory={[Function]}
18+
className="animWrap"
19+
component="div"
20+
>
21+
<div
22+
className="animWrap"
23+
>
24+
<CSSTransition
25+
classNames="mainImage"
26+
in={true}
27+
key=".$3"
28+
onExited={[Function]}
29+
timeout={500}
30+
>
31+
<Transition
32+
appear={false}
33+
enter={true}
34+
exit={true}
35+
in={true}
36+
mountOnEnter={false}
37+
onEnter={[Function]}
38+
onEntered={[Function]}
39+
onEntering={[Function]}
40+
onExit={[Function]}
41+
onExited={[Function]}
42+
onExiting={[Function]}
43+
timeout={500}
44+
unmountOnExit={false}
45+
>
46+
<img
47+
alt="main_img"
48+
className="bodyImg"
49+
src="../assets/3.png"
50+
/>
51+
</Transition>
52+
</CSSTransition>
53+
</div>
54+
</TransitionGroup>
55+
</button>
56+
</div>
57+
</Body>
58+
`;

src/__tests__/body.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { mount } from 'enzyme';
33

44
import initialState from './mocks/body';
55

6-
import { Body } from '../components';
6+
import Body from '../components/Body';
77

88
describe('<Body Component Test />', () => {
99
it('should render basic Body Component with an image', () => {
1010
const Component = mount(<Body {...initialState} />);
1111

1212
expect(Component.find('.body').length).toBe(1);
13-
expect(Component.find('.bodyImage').length).toBe(1);
13+
expect(Component.find('.bodyImg').length).toBe(1);
1414

1515
expect(Component).toMatchSnapshot();
1616
});

0 commit comments

Comments
 (0)