I have a component which utilizes tinyMCE Editor
<Editor
id='tiny-editor'
tinymceScriptSrc={'/path'}
onInit={}
value={newVal}
init{{
height: 500,
menubar: true
}}
onEditorChange={handleCommentChange}
/>
I am trying to write a test and simulate a change on the editor. I was able to get the editor by document.querySelector('#tiny-editor). I was also able to set the value on the editor using userEvent.type(editor,'a') but I am not able to simulate the onEditorChange in order to trigger my handleCommentChange function.
I have tried:
fireEvent.change(editor, {target: {value: "<p>HI</p>"}})
I have tried:
editorInstance = tinymce.get(editor.id);
fireEvent.change(editorInstance, "value")
I have tried to create a customEvent
`const eventData = new CustomEvent('input', {
bubbles: true,
cancelable: true,
detail: {
value
}}
});
fireEvent(editor, eventData);`
I have tried to do an editorInstance.setContent, editor.setValue