Fixed bug with comparing validations. Removed dynamic validations
This commit is contained in:
parent
7227895ee9
commit
aaac6d0618
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "formsy-react",
|
||||
"version": "0.12.3",
|
||||
"version": "0.12.4",
|
||||
"main": "src/main.js",
|
||||
"dependencies": {
|
||||
"react": "^0.13.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "formsy-react",
|
||||
"version": "0.12.3",
|
||||
"version": "0.12.4",
|
||||
"description": "A form input builder and validator for React JS",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ module.exports = {
|
|||
|
||||
// If validations has changed or something outside changes
|
||||
// the value, set the value again running a validation
|
||||
if (prevProps.validations !== this.props.validations || isValueChanged()) {
|
||||
if (isValueChanged()) {
|
||||
this.setValue(this.props.value);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -229,46 +229,6 @@ it('should allow an undefined value to be updated to a value', function (done) {
|
|||
}, 0);
|
||||
});
|
||||
|
||||
it('should be able to dynamically change validations', function (done) {
|
||||
|
||||
var isInvalid = false;
|
||||
var TestInput = React.createClass({
|
||||
mixins: [Formsy.Mixin],
|
||||
render: function () {
|
||||
return <input value={this.getValue()}/>
|
||||
}
|
||||
});
|
||||
var TestForm = React.createClass({
|
||||
getInitialState: function () {
|
||||
return {value: 'foo@bar.com', validations: 'isEmail'};
|
||||
},
|
||||
changeValidations: function () {
|
||||
this.setState({
|
||||
validations: 'equals:foo'
|
||||
});
|
||||
},
|
||||
setInvalid: function () {
|
||||
isInvalid = true;
|
||||
},
|
||||
render: function () {
|
||||
return (
|
||||
<Formsy.Form url="/users" onInvalid={this.setInvalid}>
|
||||
<TestInput name="A" validations={this.state.validations} value={this.state.value}/>
|
||||
</Formsy.Form>
|
||||
);
|
||||
}
|
||||
});
|
||||
var form = TestUtils.renderIntoDocument(
|
||||
<TestForm/>
|
||||
);
|
||||
|
||||
form.changeValidations();
|
||||
setTimeout(function () {
|
||||
expect(isInvalid).toBe(true);
|
||||
done();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('should be able to test a values validity', function () {
|
||||
|
||||
var isInvalid = false;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ module.exports = {
|
|||
|
||||
// If validations has changed or something outside changes
|
||||
// the value, set the value again running a validation
|
||||
if (prevProps.validations !== this.props.validations || isValueChanged()) {
|
||||
if (isValueChanged()) {
|
||||
this.setValue(this.props.value);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue