Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit fb2f318

Browse files
committed
added tests
1 parent 2331984 commit fb2f318

14 files changed

+5231
-91
lines changed

.circleci/config.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Javascript Node CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
4+
#
5+
version: 2
6+
jobs:
7+
build:
8+
docker:
9+
- image: projectstorm/react-diagrams-ci
10+
11+
working_directory: ~/repo
12+
13+
steps:
14+
- checkout
15+
16+
# Download and cache dependencies
17+
- restore_cache:
18+
keys:
19+
- v1-dependencies-{{ checksum "package.json" }}
20+
21+
- run: yarn install
22+
23+
- save_cache:
24+
paths:
25+
- node_modules
26+
key: v1-dependencies-{{ checksum "package.json" }}
27+
28+
# run tests!
29+
- run: yarn run storybook:build
30+
- run: yarn test

demos/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ storiesOf("Forms", module)
7272
</FormWidget>
7373
)
7474
})
75+
.add("Custom Buttons", () => {
76+
return (
77+
<FormWidget submitButton="Save Form" resetButton="custom reset button" formSubmitEvent={action("formSubmitEvent")}>
78+
<TableLayoutWidget>
79+
<FieldElementWidget name="Name" />
80+
<FieldElementWidget name="Surname" />
81+
</TableLayoutWidget>
82+
</FormWidget>
83+
)
84+
})
7585
.add("Simple Form with nested groups", () => {
7686
return (
7787
<FormWidget formSubmitEvent={action("formSubmitEvent")}>

jest.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// jest.config.js
2+
module.exports = {
3+
verbose: true,
4+
moduleFileExtensions: ["ts", "tsx", "js", "json"],
5+
transform: {
6+
"^.+\\.(ts|tsx)$": "./tests/helpers/tsx-preprocessor.js",
7+
"^.+\\.(scss)$": "./tests/helpers/scss-preprocessor.js"
8+
},
9+
moduleNameMapper:{
10+
"\\.(css|less)$": __dirname+"/tests/helpers/stylemock.js"
11+
},
12+
"testMatch": [
13+
"**/tests/*\.test\.*"
14+
]
15+
};

package.json

Lines changed: 61 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,63 @@
11
{
2-
"name": "storm-react-forms",
3-
"main": "./dist/main.js",
4-
"typings": "./dist/@types/main",
5-
"repository": {
6-
"type": "git",
7-
"url": "https://github.com/projectstorm/react-forms.git"
8-
},
9-
"keywords": [
10-
"web",
11-
"forms",
12-
"form",
13-
"react",
14-
"typescript",
15-
"simple"
16-
],
17-
"author": "dylanvorster",
18-
"scripts": {
19-
"storybook": "start-storybook -p 9001 -c .storybook",
20-
"storybook:build": "build-storybook -c .storybook -o .out",
21-
"storybook:github": "storybook-to-ghpages",
22-
"prepublishOnly": "export NODE_ENV=production && webpack",
23-
"lintjs": "prettier --use-tabs --write \"{src,demos}/**/*.{ts,tsx}\" --print-width 120"
24-
},
25-
"dependencies": {
26-
"lodash": "^4.17.4",
27-
"prop-types": "^15.6.0",
28-
"react": "^16.1.1",
29-
"react-dom": "^16.1.1"
30-
},
31-
"devDependencies": {
32-
"@storybook/addon-notes": "^3.2.16",
33-
"@storybook/react": "^3.2.16",
34-
"@storybook/storybook-deployer": "^2.0.0",
35-
"@types/lodash": "^4.14.85",
36-
"@types/prop-types": "^15.5.2",
37-
"@types/react": "^16.0.25",
38-
"@types/react-dom": "^16.0.3",
39-
"awesome-typescript-loader": "^3.4.0",
40-
"css-loader": "^0.28.7",
41-
"extract-text-webpack-plugin": "^3.0.2",
42-
"file-loader": "^1.1.5",
43-
"node-sass": "^4.7.2",
44-
"prettier": "^1.8.2",
45-
"sass-loader": "^6.0.6",
46-
"source-map-loader": "^0.2.3",
47-
"storybook-host": "^4.1.4",
48-
"style-loader": "^0.19.0",
49-
"typescript": "^2.6.1",
50-
"webpack": "^3.8.1",
51-
"webpack-livereload-plugin": "^1.0.0",
52-
"webpack-node-externals": "^1.6.0",
53-
"webpack-notifier": "^1.5.0"
54-
},
55-
"version": "0.1.1"
2+
"name": "storm-react-forms",
3+
"main": "./dist/main.js",
4+
"typings": "./dist/@types/main",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/projectstorm/react-forms.git"
8+
},
9+
"keywords": [
10+
"web",
11+
"forms",
12+
"form",
13+
"react",
14+
"typescript",
15+
"simple"
16+
],
17+
"author": "dylanvorster",
18+
"scripts": {
19+
"test": "jest",
20+
"storybook": "start-storybook -p 9001 -c .storybook",
21+
"storybook:build": "build-storybook -c .storybook -o .out",
22+
"storybook:github": "storybook-to-ghpages",
23+
"prepublishOnly": "export NODE_ENV=production && webpack",
24+
"lintjs": "prettier --use-tabs --write \"{src,demos}/**/*.{ts,tsx}\" --print-width 120"
25+
},
26+
"dependencies": {
27+
"lodash": "^4.17.4",
28+
"prop-types": "^15.6.0",
29+
"react": "^16.1.1",
30+
"react-dom": "^16.1.1"
31+
},
32+
"devDependencies": {
33+
"@storybook/addon-notes": "^3.2.16",
34+
"@storybook/addon-storyshots": "^3.2.16",
35+
"@storybook/react": "^3.2.16",
36+
"@storybook/storybook-deployer": "^2.0.0",
37+
"@types/lodash": "^4.14.85",
38+
"@types/prop-types": "^15.5.2",
39+
"@types/react": "^16.0.25",
40+
"@types/react-dom": "^16.0.3",
41+
"awesome-typescript-loader": "^3.4.0",
42+
"css-loader": "^0.28.7",
43+
"extract-text-webpack-plugin": "^3.0.2",
44+
"file-loader": "^1.1.5",
45+
"jest": "^21.2.1",
46+
"jest-cli": "^21.2.1",
47+
"node-sass": "^4.7.2",
48+
"prettier": "^1.8.2",
49+
"puppeteer": "^0.13.0",
50+
"raf": "^3.4.0",
51+
"react-test-renderer": "^16.1.1",
52+
"sass-loader": "^6.0.6",
53+
"source-map-loader": "^0.2.3",
54+
"storybook-host": "^4.1.4",
55+
"style-loader": "^0.19.0",
56+
"typescript": "^2.6.1",
57+
"webpack": "^3.8.1",
58+
"webpack-livereload-plugin": "^1.0.0",
59+
"webpack-node-externals": "^1.6.0",
60+
"webpack-notifier": "^1.5.0"
61+
},
62+
"version": "0.1.1"
5663
}

tests/1.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import initStoryshots from '@storybook/addon-storyshots';
2+
import 'raf/polyfill';
3+
4+
initStoryshots({
5+
storyKindRegex: /Elements/
6+
});

tests/2.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import initStoryshots from '@storybook/addon-storyshots';
2+
import 'raf/polyfill';
3+
4+
initStoryshots({
5+
storyKindRegex: /Forms/
6+
});

tests/3.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import initStoryshots from '@storybook/addon-storyshots';
2+
import 'raf/polyfill';
3+
4+
initStoryshots({
5+
storyKindRegex: /Binded Forms/
6+
});

0 commit comments

Comments
 (0)