Skip to content

Commit

Permalink
chore(useForm): create useForm hook
Browse files Browse the repository at this point in the history
- install @testing-library/react-hooks, validatorjs
- install react-test-renderer
- create a useForm.js in src/hooks
- crete useForm.spec.js in scr/hooks/test
- create useForm fixture in scr/fixtures/hooks

[Chores #167303083]
  • Loading branch information
Eazybee committed Jul 15, 2019
1 parent 363cd0a commit 4639a3a
Show file tree
Hide file tree
Showing 5 changed files with 316 additions and 27 deletions.
117 changes: 92 additions & 25 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@babel/runtime": "^7.3.4",
"@testing-library/jest-dom": "^4.0.0",
"@testing-library/react": "^8.0.5",
"@testing-library/react-hooks": "^1.1.0",
"autoprefixer": "^9.4.10",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
Expand All @@ -90,6 +91,7 @@
"lint-staged": "^9.0.0",
"mini-css-extract-plugin": "^0.7.0",
"react-styleguidist": "^9.1.11",
"react-test-renderer": "^16.8.6",
"style-loader": "^0.23.1",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack-dev-server": "^3.2.1"
Expand All @@ -102,9 +104,10 @@
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.1",
"styled-components": "^4.3.2",
"styled-icons": "^8.1.0",
"validatorjs": "^3.15.1",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.6",
"webpack-merge": "^4.2.1",
"styled-icons": "^8.1.0"
"webpack-merge": "^4.2.1"
}
}
24 changes: 24 additions & 0 deletions src/fixtures/hooks/useForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const rules = {
username: 'required|alpha',
id: 'numeric',
};

export const event = {
target: {
value: 'EazyBee',
name: 'username',
},
};

export const getEvent = (newObject) => {
return {
target: {
...event.target,
...newObject,
},
};
};

export const callback = (values) => {
return ['callback called', values];
};
Loading

0 comments on commit 4639a3a

Please sign in to comment.