in my code, i have component that using react-ace. in my render function i have this row:
<CodeEditor onChange={onCodeChanged} value={code} />
callback function:
const onCodeBodyChanged = (newCode) => {
// some code ...
dispatch(setResource({ newCode }));
}
I want to test onCodeChanged
via RTL, so I tried to find the text area on change the value, but without any success
example of (not working) test:
const { container } = render(<ResourceEditorPanel />, createMockStore());
const ace = container.querySelectorAll('.ace_text-input');
fireEvent.change(ace, { target: { value: 'someText' } });
await waitFor(() => {
expect(dispatch).toHaveBeenCalled();
});
the problem is fireEvent.change(ace, { target: { value: 'someText' } });
doesn't trigger my function - onCodeChanged.
Do you know how can I test it?
fireEvent.click(editorInputField);
was not necessary for me. – Gapes