Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Commit

Permalink
Testing components (#41)
Browse files Browse the repository at this point in the history
Testing components
  • Loading branch information
piyush97 authored Aug 14, 2019
2 parents da1687c + 8dfb3c2 commit a4bb10f
Show file tree
Hide file tree
Showing 13 changed files with 2,239 additions and 250 deletions.
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'test-file-stub';
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
112 changes: 67 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
"storybook": "start-storybook -p 9001 -c src/.storybook",
"watch-css": "npm run build-css && node-sass-chokidar src/components/ -o src/components/ --watch --recursive"
},
"jest": {
"moduleNameMapper": {
"\\.(css|less|sass|scss)$": "<rootDir>/__mocks__/styleMock.js",
"\\.(gif|ttf|eot|svg)$": "identity-obj-proxy"
}
},
"storybook-deployer": {
"gitUsername": "piyush97",
"gitEmail": "[email protected]",
Expand Down Expand Up @@ -87,6 +93,7 @@
"eslint-watch": "^6.0.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"husky": "^1.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.8.0",
"lint-staged": "^8.1.0",
"mini-css-extract-plugin": "^0.8.0",
Expand All @@ -96,9 +103,9 @@
"prettier": "^1.18.2",
"pretty-quick": "^1.11.1",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-test-renderer": "^16.9.0",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-test-renderer": "^16.8.6",
"sass-loader": "^7.1.0",
"storybook-addon-jsx": "^7.1.5",
"style-loader": "^1.0.0",
Expand Down
22 changes: 22 additions & 0 deletions src/components/Box/__snapshots__/box.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`box default test case 1`] = `
<div
className="Primary"
style={
Object {
"color": "white",
"margin": "2.5em",
"padding": "2em",
"textColor": Object {
"textColor": "white",
},
}
}
>
This is:
Primary
with textColor:
white
</div>
`;
12 changes: 12 additions & 0 deletions src/components/Box/box.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Box from './index';

test('box default test case',()=>{
const component = renderer.create(
<Box color="Primary" p={2} m={2.5} />
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});

Loading

0 comments on commit a4bb10f

Please sign in to comment.