Skip to content

Commit

Permalink
Added tests in the app. Added Jest dev and peer packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
BiosBoy committed Jan 8, 2019
1 parent 74949f5 commit 57725dc
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 509 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## Webpack4 - React16.7 Templater App


# 1.7.1
* Added Jest dev and peer packages.
* Fixed Jest testing environment.
* Minor improvements.

# 1.4.0
* Added Tests example in the App.
* Fixed animation in App Component.
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ module.exports = {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.tsx?$': 'ts-jest'
},
setupFiles: ['<rootDir>/setupTests.js', '<rootDir>/node_modules/whatwg-fetch/fetch.js'],
setupFiles: ['<rootDir>/setupTests.js'],
snapshotSerializers: ['enzyme-to-json/serializer']
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"eslint-plugin-react": "^7.12.1",
"eslint-plugin-react-hooks": "^0.0.0",
"husky": "^1.3.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^23.6.0",
"jest-cli": "^23.6.0",
"jsonlint": "^1.6.3",
Expand Down Expand Up @@ -160,6 +161,8 @@
"@babel/preset-stage-3": "^7.0.0",
"@babel/preset-typescript": "^7.1.0",
"awesome-typescript-loader": "^5.2.1",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.5",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
Expand All @@ -169,6 +172,7 @@
"connect-history-api-fallback": "^1.5.0",
"connected-react-router": "^6.1.0",
"debug": "^4.1.1",
"enzyme-adapter-react-16": "^1.7.1",
"eslint-loader": "^2.1.1",
"exports-loader": "^0.7.0",
"history": "^4.7.2",
Expand Down
58 changes: 58 additions & 0 deletions src/__tests__/__snapshots__/body.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Body Component Test /> should render basic Body Component with an image 1`] = `
<Body
imageToShow={3}
switchImage={[Function]}
>
<div
className="body"
>
<button
className="button"
onClick={[Function]}
type="button"
>
<TransitionGroup
childFactory={[Function]}
className="animWrap"
component="div"
>
<div
className="animWrap"
>
<CSSTransition
classNames="mainImage"
in={true}
key=".$3"
onExited={[Function]}
timeout={500}
>
<Transition
appear={false}
enter={true}
exit={true}
in={true}
mountOnEnter={false}
onEnter={[Function]}
onEntered={[Function]}
onEntering={[Function]}
onExit={[Function]}
onExited={[Function]}
onExiting={[Function]}
timeout={500}
unmountOnExit={false}
>
<img
alt="main_img"
className="bodyImg"
src="../assets/3.png"
/>
</Transition>
</CSSTransition>
</div>
</TransitionGroup>
</button>
</div>
</Body>
`;
4 changes: 2 additions & 2 deletions src/__tests__/body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { mount } from 'enzyme';

import initialState from './mocks/body';

import { Body } from '../components';
import Body from '../components/Body';

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

expect(Component.find('.body').length).toBe(1);
expect(Component.find('.bodyImage').length).toBe(1);
expect(Component.find('.bodyImg').length).toBe(1);

expect(Component).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit 57725dc

Please sign in to comment.