Skip to content

Commit 60973b7

Browse files
authored
start tests (codesandbox#2322)
* start-tesrts * add svg mock * more themes * fix jest * fix ling * delete obsolete * revert eslint * remove dep * fix import
1 parent 11f13c7 commit 60973b7

File tree

40 files changed

+1020
-29
lines changed

40 files changed

+1020
-29
lines changed

packages/app/src/app/pages/Patron/PricingModal/PricingChoice/Range/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import Slider from 'rc-slider/lib/Slider';
3-
import 'rc-slider/assets/index.css';
3+
import 'rc-slider/dist/rc-slider.css';
44

55
function Range(props) {
66
return (

packages/app/src/app/pages/Sandbox/Editor/Navigation/Navigation.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ import { inject, hooksObserver } from 'app/componentConnectors';
33
import PlusIcon from 'react-icons/lib/go/plus';
44
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
55
// @ts-ignore
6+
// eslint-disable-next-line import/no-unresolved
67
import InfoIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/sandbox.svg';
78
// @ts-ignore
9+
// eslint-disable-next-line import/no-unresolved
810
import GitHubIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/github.svg';
911
// @ts-ignore
12+
// eslint-disable-next-line import/no-unresolved
1013
import LiveIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/live.svg';
1114
// @ts-ignore
15+
// eslint-disable-next-line import/no-unresolved
1216
import FilesIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/file.svg';
1317
// @ts-ignore
18+
// eslint-disable-next-line import/no-unresolved
1419
import RocketIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/rocket.svg';
1520
// @ts-ignore
21+
// eslint-disable-next-line import/no-unresolved
1622
import ConfigurationIcon from '-!svg-react-loader!@codesandbox/common/lib/icons/cog.svg';
1723
import getWorkspaceItems, {
1824
getDisabledItems,

packages/common/package.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lib"
1212
],
1313
"scripts": {
14-
"test": "jest",
14+
"test": "NODE_ENV=test jest",
1515
"clean": "rimraf lib && yarn rimraf node_modules/@types/react-native",
1616
"start": "(yarn tsc --watch & yarn babel src --out-dir lib --watch & yarn cpx \"src/**/*.{css,svg,png,jpg}\" lib --watch)",
1717
"start:storybook": "start-storybook",
@@ -30,6 +30,7 @@
3030
"@sentry/browser": "^5.6.2",
3131
"@tippy.js/react": "^2.1.1",
3232
"babel-plugin-preval": "^3.0.1",
33+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
3334
"codesandbox-api": "^0.0.22",
3435
"color": "0.11.4",
3536
"date-fns": "^2.0.0",
@@ -60,6 +61,7 @@
6061
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
6162
"@babel/plugin-transform-async-to-generator": "^7.5.0",
6263
"@babel/plugin-transform-runtime": "^7.5.5",
64+
"@codesandbox/template-icons": "^0.7.0",
6365
"@storybook/addon-a11y": "^5.1.11",
6466
"@storybook/addon-actions": "^5.1.9",
6567
"@storybook/addon-knobs": "^5.1.9",
@@ -81,16 +83,29 @@
8183
"babel-plugin-macros": "^2.6.1",
8284
"babel-plugin-system-import-transformer": "^4.0.0",
8385
"cpx": "^1.5.0",
86+
"enzyme": "^3.10.0",
87+
"enzyme-adapter-react-16": "^1.14.0",
88+
"enzyme-to-json": "^3.4.0",
8489
"jest": "^24.8.0",
90+
"jest-environment-enzyme": "^7.1.0",
91+
"jest-enzyme": "^7.1.0",
92+
"jest-styled-components": "^6.3.3",
93+
"jest-svg-transformer": "^1.0.0",
8594
"rimraf": "^2.6.3",
86-
"typescript": "3.5.2"
95+
"typescript": "3.5.2",
96+
"yarn": "^1.17.3"
8797
},
8898
"jest": {
99+
"testEnvironment": "enzyme",
100+
"setupFilesAfterEnv": [
101+
"<rootDir>src/test/setupTests.ts"
102+
],
89103
"moduleDirectories": [
90104
"node_modules"
91105
],
92106
"transform": {
93-
"^.+\\.(t|j)s$": "babel-jest"
107+
"^.+\\.[t|j]sx?$": "babel-jest",
108+
"^.+\\.svg$": "jest-svg-transformer"
94109
},
95110
"modulePathIgnorePatterns": [
96111
"lib"
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<AutosizeInput /> rendering renders correctly 1`] = `ReactWrapper {}`;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'jest-styled-components';
2+
import React from 'react';
3+
import mountWithTheme from '../../test/themeMount';
4+
import AutosizeInput from '.';
5+
6+
describe('<AutosizeInput /> rendering', () => {
7+
it('renders correctly', () => {
8+
expect(mountWithTheme(<AutosizeInput />)).toMatchSnapshot();
9+
});
10+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<AutosizeTextArea /> rendering renders correctly 1`] = `ReactWrapper {}`;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'jest-styled-components';
2+
import React from 'react';
3+
import mountWithTheme from '../../test/themeMount';
4+
import AutosizeTextArea from './';
5+
6+
describe('<AutosizeTextArea /> rendering', () => {
7+
it('renders correctly', () => {
8+
expect(mountWithTheme(<AutosizeTextArea />)).toMatchSnapshot();
9+
});
10+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Button /> rendering Danger Button 1`] = `ReactWrapper {}`;
4+
5+
exports[`<Button /> rendering Href Button 1`] = `ReactWrapper {}`;
6+
7+
exports[`<Button /> rendering Secondary Button 1`] = `ReactWrapper {}`;
8+
9+
exports[`<Button /> rendering Small Button 1`] = `ReactWrapper {}`;
10+
11+
exports[`<Button /> rendering block Button 1`] = `ReactWrapper {}`;
12+
13+
exports[`<Button /> rendering no props 1`] = `ReactWrapper {}`;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import 'jest-styled-components';
2+
import React from 'react';
3+
import mountWithTheme from '../../test/themeMount';
4+
import { Button } from '.';
5+
6+
describe('<Button /> rendering', () => {
7+
it('no props', () => {
8+
expect(mountWithTheme(<Button>Le button</Button>)).toMatchSnapshot();
9+
});
10+
it('Danger Button', () => {
11+
expect(mountWithTheme(<Button danger>Le button</Button>)).toMatchSnapshot();
12+
});
13+
it('Secondary Button', () => {
14+
expect(
15+
mountWithTheme(<Button secondary>Le button</Button>)
16+
).toMatchSnapshot();
17+
});
18+
it('Small Button', () => {
19+
expect(mountWithTheme(<Button small>Le button</Button>)).toMatchSnapshot();
20+
});
21+
it('block Button', () => {
22+
expect(mountWithTheme(<Button block>Le button</Button>)).toMatchSnapshot();
23+
});
24+
25+
it('Href Button', () => {
26+
expect(
27+
mountWithTheme(<Button href="#">Le button</Button>)
28+
).toMatchSnapshot();
29+
});
30+
});

0 commit comments

Comments
 (0)