Permalink
Browse files

Fix filter bug

  • Loading branch information...
zackify committed Sep 27, 2017
1 parent c34b670 commit fda279302fc4ede78c3f766400266cc6091a515e
Showing with 9 additions and 9 deletions.
  1. +1 −1 package.json
  2. +1 −1 src/input.js
  3. +7 −7 tests/inputs.js
View
@@ -1,6 +1,6 @@
{
"name": "react-validify",
"version": "2.0.9",
"version": "2.0.10",
"description": "Form validation made easy",
"main": "dist/form.js",
"directories": {
View
@@ -9,7 +9,7 @@ const filters = {
};
const getValue = (type, values) => {
let filter = filters[type || 'text'];
let filter = filters[type] || filters.text;
let value = filter(values.filter(filter)[0]);
if (value || value === false) return value;
View
@@ -13,25 +13,25 @@ test('Input is passed in value correctly', () => {
</Form>
);
wrapper
.find(Input)
.simulate('change', {
target: { name: 'Awesome', value: 'yes', checked: false },
});
wrapper.find(Input).simulate('change', {
target: { name: 'Awesome', value: 'yes', checked: false },
});
expect(wrapper.find(Input).props().value).toEqual('yes');
});
test('Input gets error message', () => {
const wrapper = shallow(
<Form rules={{ Awesome: 'required|min:8' }}>
<Input name="Awesome" />
<Input name="Awesome" type="password" />
</Form>
);
wrapper
.find(Input)
.simulate('change', { target: { name: 'Awesome', value: 'fail' } });
.simulate('change', {
target: { name: 'Awesome', value: 'fail', type: 'password' },
});
wrapper.find(Input).simulate('blur');
expect(wrapper.find(Input).props().error).toEqual(

0 comments on commit fda2793

Please sign in to comment.