Skip to content

Commit 42dbcfb

Browse files
committed
Fix tests
1 parent 7a4cf45 commit 42dbcfb

20 files changed

+54
-65
lines changed

lib/Wrapper.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,23 +232,23 @@ exports.default = function (Component) {
232232
value: function render() {
233233
var innerRef = this.props.innerRef;
234234

235-
var propsForElement = _extends({
236-
getErrorMessage: this.getErrorMessage,
237-
getErrorMessages: this.getErrorMessages,
238-
getValue: this.getValue,
239-
hasValue: this.hasValue,
240-
isFormDisabled: this.isFormDisabled,
241-
isValid: this.isValid,
242-
isPristine: this.isPristine,
243-
isFormSubmitted: this.isFormSubmitted,
244-
isRequired: this.isRequired,
235+
var propsForElement = _extends({}, this.props, {
236+
errorMessage: this.getErrorMessage(),
237+
errorMessages: this.getErrorMessages(),
238+
hasValue: this.hasValue(),
239+
isFormDisabled: this.isFormDisabled(),
240+
isFormSubmitted: this.isFormSubmitted(),
241+
isPristine: this.isPristine(),
242+
isRequired: this.isRequired(),
243+
isValid: this.isValid(),
245244
isValidValue: this.isValidValue,
246245
resetValue: this.resetValue,
247246
setValidations: this.setValidations,
248247
setValue: this.setValue,
249-
showRequired: this.showRequired,
250-
showError: this.showError
251-
}, this.props);
248+
showError: this.showError(),
249+
showRequired: this.showRequired(),
250+
value: this.getValue()
251+
});
252252

253253
if (innerRef) {
254254
propsForElement.ref = innerRef;

release/formsy-react.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

release/formsy-react.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Element-spec.js

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import immediate from './utils/immediate';
99

1010
export default {
1111

12-
'should return passed and setValue() value when using getValue()': function (test) {
12+
'should pass down correct value prop after using setValue()': function (test) {
1313

1414
const form = TestUtils.renderIntoDocument(
1515
<Formsy>
@@ -33,7 +33,7 @@ export default {
3333
this.props.setValue(event.target.value, false);
3434
}
3535
render() {
36-
return <input type="text" value={this.props.getValue()} onChange={this.updateValue}/>;
36+
return <input type="text" value={this.props.value} onChange={this.updateValue}/>;
3737
}
3838
})
3939
const form = TestUtils.renderIntoDocument(
@@ -60,7 +60,7 @@ export default {
6060
this.props.setValue(event.target.value, false);
6161
}
6262
render() {
63-
return <input type="text" value={this.props.getValue()} onChange={this.updateValue}/>;
63+
return <input type="text" value={this.props.value} onChange={this.updateValue}/>;
6464
}
6565
})
6666
const form = TestUtils.renderIntoDocument(
@@ -105,10 +105,10 @@ export default {
105105

106106
'should return error message passed when calling getErrorMessage()': function (test) {
107107

108-
let getErrorMessage = null;
108+
let errorMessage = null;
109109
const Input = InputFactory({
110110
componentDidMount: function() {
111-
getErrorMessage = this.props.getErrorMessage;
111+
errorMessage = this.props.errorMessage;
112112
}
113113
});
114114
TestUtils.renderIntoDocument(
@@ -117,7 +117,7 @@ export default {
117117
</Formsy>
118118
);
119119

120-
test.equal(getErrorMessage(), 'Has to be email');
120+
test.equal(errorMessage, 'Has to be email');
121121

122122
test.done();
123123

@@ -127,8 +127,8 @@ export default {
127127

128128
let isValid = null;
129129
const Input = InputFactory({
130-
componentDidMount: function() {
131-
isValid = this.props.isValid;
130+
componentWillReceiveProps: function(nextProps) {
131+
isValid = nextProps.isValid;
132132
}
133133
});
134134
const form = TestUtils.renderIntoDocument(
@@ -137,10 +137,10 @@ export default {
137137
</Formsy>
138138
);
139139

140-
test.equal(isValid(), false);
140+
test.equal(isValid, false);
141141
const input = TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT');
142142
TestUtils.Simulate.change(input, {target: {value: 'foo@foo.com'}});
143-
test.equal(isValid(), true);
143+
test.equal(isValid, true);
144144

145145
test.done();
146146

@@ -162,9 +162,9 @@ export default {
162162
</Formsy>
163163
);
164164

165-
test.equal(isRequireds[0](), false);
166-
test.equal(isRequireds[1](), true);
167-
test.equal(isRequireds[2](), true);
165+
test.equal(isRequireds[0], false);
166+
test.equal(isRequireds[1], true);
167+
test.equal(isRequireds[2], true);
168168

169169
test.done();
170170

@@ -186,9 +186,9 @@ export default {
186186
</Formsy>
187187
);
188188

189-
test.equal(showRequireds[0](), false);
190-
test.equal(showRequireds[1](), true);
191-
test.equal(showRequireds[2](), false);
189+
test.equal(showRequireds[0], false);
190+
test.equal(showRequireds[1], true);
191+
test.equal(showRequireds[2], false);
192192

193193
test.done();
194194

@@ -198,8 +198,8 @@ export default {
198198

199199
let isPristine = null;
200200
const Input = InputFactory({
201-
componentDidMount: function() {
202-
isPristine = this.props.isPristine;
201+
componentWillReceiveProps: function(nextProps) {
202+
isPristine = nextProps.isPristine;
203203
}
204204
});
205205
const form = TestUtils.renderIntoDocument(
@@ -208,10 +208,10 @@ export default {
208208
</Formsy>
209209
);
210210

211-
test.equal(isPristine(), true);
211+
test.equal(isPristine, true);
212212
const input = TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT');
213213
TestUtils.Simulate.change(input, {target: {value: 'foo'}});
214-
test.equal(isPristine(), false);
214+
test.equal(isPristine, false);
215215

216216
test.done();
217217

@@ -594,7 +594,7 @@ export default {
594594
shouldComponentUpdate: function() { return false },
595595
render: function() {
596596
renderSpy();
597-
return <input type={this.props.type} value={this.props.getValue()} onChange={this.updateValue}/>;
597+
return <input type={this.props.type} value={this.props.value} onChange={this.updateValue}/>;
598598
}
599599
});
600600

@@ -613,21 +613,10 @@ export default {
613613
'binds all necessary methods': function (test) {
614614
const onInputRef = input => {
615615
[
616-
'getErrorMessage',
617-
'getErrorMessages',
618-
'getValue',
619-
'hasValue',
620-
'isFormDisabled',
621-
'isValid',
622-
'isPristine',
623-
'isFormSubmitted',
624-
'isRequired',
625616
'isValidValue',
626617
'resetValue',
627618
'setValidations',
628619
'setValue',
629-
'showRequired',
630-
'showError',
631620
].forEach(fnName => {
632621
const fn = input[fnName];
633622
try {

tests/Rules-equals-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { InputFactory } from './utils/TestInput';
77

88
const TestInput = InputFactory({
99
render: function() {
10-
return <input value={this.props.getValue()} readOnly />;
10+
return <input value={this.props.value} readOnly />;
1111
}
1212
});
1313

tests/Rules-isAlpha-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InputFactory } from './utils/TestInput';
66

77
const TestInput = InputFactory({
88
render: function() {
9-
return <input value={this.props.getValue()} readOnly />;
9+
return <input value={this.props.value} readOnly />;
1010
}
1111
});
1212

tests/Rules-isAlphanumeric-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InputFactory } from './utils/TestInput';
66

77
const TestInput = InputFactory({
88
render() {
9-
return <input value={this.props.getValue()} readOnly/>;
9+
return <input value={this.props.value} readOnly/>;
1010
}
1111
});
1212

tests/Rules-isEmail-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InputFactory } from './utils/TestInput';
66

77
const TestInput = InputFactory({
88
render() {
9-
return <input value={this.props.getValue()} readOnly/>;
9+
return <input value={this.props.value} readOnly/>;
1010
}
1111
});
1212

tests/Rules-isEmptyString-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InputFactory } from './utils/TestInput';
66

77
const TestInput = InputFactory({
88
render() {
9-
return <input value={this.props.getValue()} readOnly/>;
9+
return <input value={this.props.value} readOnly/>;
1010
}
1111
});
1212

tests/Rules-isExisty-spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { InputFactory } from './utils/TestInput';
66

77
const TestInput = InputFactory({
88
render() {
9-
return <input value={this.props.getValue()} readOnly/>;
9+
return <input value={this.props.value} readOnly/>;
1010
}
1111
});
1212

0 commit comments

Comments
 (0)