Skip to content

Commit

Permalink
updated dev dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrii_Nikolaev committed Sep 11, 2017
1 parent c98675c commit 8c9fbab
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
5 changes: 3 additions & 2 deletions app/components/validation-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ValidationInput extends Component {
return (
<div>
{element}
{error &&
{error && (
<div
style={{
color: 'red',
Expand All @@ -81,7 +81,8 @@ class ValidationInput extends Component {
<div className={className} style={style}>
{errorCodes[error] || error}
</div>
</div>}
</div>
)}
</div>
);
}
Expand Down
36 changes: 12 additions & 24 deletions app/validation.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,17 @@ const aliasedRules = [
];

storiesOf('Validation', module)
.add('default', () =>
.add('default', () => (
<Validation schema={schema} data={{}}>
<form>
<Row>
<Label htmlFor={LOGIN}>
{LOGIN}
</Label>
<Label htmlFor={LOGIN}>{LOGIN}</Label>
<ValidationInput name={LOGIN}>
<Input id={LOGIN} type="text" name={LOGIN} />
</ValidationInput>
</Row>
<Row>
<Label htmlFor={PASSWORD}>
{PASSWORD}
</Label>
<Label htmlFor={PASSWORD}>{PASSWORD}</Label>
<ValidationInput name={PASSWORD}>
<Input id={PASSWORD} type="password" name={PASSWORD} />
</ValidationInput>
Expand All @@ -63,8 +59,8 @@ storiesOf('Validation', module)
</DisabledOnErrors>
</form>
</Validation>
)
.add('custom validation rules', () =>
))
.add('custom validation rules', () => (
<Validation
schema={customSchema}
aliasedRules={aliasedRules}
Expand All @@ -73,17 +69,13 @@ storiesOf('Validation', module)
>
<form>
<Row>
<Label htmlFor={LOGIN}>
{LOGIN}
</Label>
<Label htmlFor={LOGIN}>{LOGIN}</Label>
<ValidationInput name={LOGIN}>
<Input id={LOGIN} type="text" name={LOGIN} />
</ValidationInput>
</Row>
<Row>
<Label htmlFor={PASSWORD}>
{PASSWORD}
</Label>
<Label htmlFor={PASSWORD}>{PASSWORD}</Label>
<ValidationInput name={PASSWORD}>
<Input id={PASSWORD} type="password" name={PASSWORD} />
</ValidationInput>
Expand All @@ -93,8 +85,8 @@ storiesOf('Validation', module)
</DisabledOnErrors>
</form>
</Validation>
)
.add('styled error block', () =>
))
.add('styled error block', () => (
<Validation
schema={schema}
data={{}}
Expand All @@ -106,17 +98,13 @@ storiesOf('Validation', module)
>
<form>
<Row>
<Label htmlFor={LOGIN}>
{LOGIN}
</Label>
<Label htmlFor={LOGIN}>{LOGIN}</Label>
<ValidationInput name={LOGIN}>
<Input id={LOGIN} type="text" name={LOGIN} />
</ValidationInput>
</Row>
<Row>
<Label htmlFor={PASSWORD}>
{PASSWORD}
</Label>
<Label htmlFor={PASSWORD}>{PASSWORD}</Label>
<ValidationInput name={PASSWORD}>
<Input id={PASSWORD} type="password" name={PASSWORD} />
</ValidationInput>
Expand All @@ -126,7 +114,7 @@ storiesOf('Validation', module)
</DisabledOnErrors>
</form>
</Validation>
);
));

const Input = styled.input`margin-top: 10px;`;

Expand Down
24 changes: 20 additions & 4 deletions app/validation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,21 @@ describe('Validation', () => {
}
});
expect(
wrapper.find(ValidationInput).at(0).find('[data-error-block]')
wrapper
.find(ValidationInput)
.at(0)
.find('[data-error-block]')
).toHaveLength(1);
wrapper.find(`input[name="${LOGIN}"]`).simulate('change', {
target: {
value: ''
}
});
expect(
wrapper.find(ValidationInput).at(1).find('[data-error-block]')
wrapper
.find(ValidationInput)
.at(1)
.find('[data-error-block]')
).toHaveLength(1);
expect(wrapper.find('button').props().disabled).toBeTruthy();

Expand All @@ -99,13 +105,23 @@ describe('Validation', () => {
value: '123'
}
});
expect(wrapper.find(ValidationInput).at(0).find('div')).toHaveLength(1);
expect(
wrapper
.find(ValidationInput)
.at(0)
.find('div')
).toHaveLength(1);
wrapper.find(`input[name="${LOGIN}"]`).simulate('change', {
target: {
value: '456'
}
});
expect(wrapper.find(ValidationInput).at(1).find('div')).toHaveLength(1);
expect(
wrapper
.find(ValidationInput)
.at(1)
.find('div')
).toHaveLength(1);
expect(wrapper.find('button').props().disabled).toBeFalsy();
});

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-livr-validation",
"version": "1.0.3",
"version": "1.0.4",
"description": "react validation component with LIVR as validation engine",
"main": "dist/bundle.js",
"scripts": {
Expand Down Expand Up @@ -49,10 +49,13 @@
"react": "^15.6.1"
},
"devDependencies": {
"@storybook/react": "^3.2.8",
"babel-eslint": "^7.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.0.5",
"enzyme": "^2.9.1",
"eslint": "^4.4.1",
Expand Down

0 comments on commit 8c9fbab

Please sign in to comment.