In this lesson we walk through four different sets of tests. We have a built out form that on submit, sends an ajax request with the inputed information. We walk through how we can test default options, simulate user input, actually submitting the form, and saving a snapshot of the form's layout.
Great course first off! I am curious what is the difference between using the it() method to describe a test, or the test() method?
There is a bug in updateInput()
: It has to be target
, not currentTarget
.
Correct version:
const updateInput = (wrapper, instance, newValue) => {
const input = wrapper.find(instance)
input.simulate('change', {
target: {value: newValue}
})
return wrapper.find(instance)
}
Why couldn't you just return input
instead of finding the instance
again?
const updateInput = (wrapper, instance, newValue) => {
const input = wrapper.find(instance)
input.simulate('change', {
target: {value: newValue}
})
return input // <------- why not?
}