Reputation: 1010
I have this code in test
let formatField = subject.find("input").at(0);
(formatField.props() as any).onChange({
currentTarget: { value: "Potato" }
});
The problem is after this action when I get formatField.props().value
it still undefined
Do I missing something?
I tried with
formatField .simulate('change', { target: { value: 'Potato' } });
and also
formatField .simulate('keydown', { keyCode: 13 });
the value still not update
Thank you very much!
Upvotes: 1
Views: 169
Reputation: 1010
I found it by my self: need to wait for it update
const waitForAsync = () => new Promise(resolve => setImmediate(resolve));
await waitForAsync();
subject.update();
also the simulate change event should like this
formatField.simulate("change", {
target: { value: "my value" }
});
Upvotes: 1