Tests with PluginEditor

Hallo,

I implemented a component, which uses the [Plugin-Editor]<INTERNAL_LINK>.
Now I want to write a jest test with enzyme to proof the behaviour of my component.
If it would be a simple Textfield I would write:

editorInput.simulate("change", { target: { value: "Label" } });

But because of the fact, that the PluginEditor uses the DraftJs-Editor, that doesn’t work.
Did anybody had the some issue? And how did you solve it?

Best regards
Nora

Hi,

you can use the handleOnChange method of the pluginEditor to change its content. Something like this where PluginEditorComponent is the name of your component.

const pluginEditorComponent = editorInput.instance() as PluginEditorComponent;
pluginEditorComponent.handleOnChange(
    EditorState.createWithConent(ContentState.createFromText("Label"))
)