jpuri / react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
MIT License
6.41k stars 1.16k forks source link

Test cases #1249

Open rexconsul opened 2 years ago

rexconsul commented 2 years ago

Hello! Just wanted to ask if there is any test cases references on how to test for the onChange handler of the editor? I only tested the render of the component. Below is my current code. I'm using react-testing-library as of the moment. Any help would be appreciated. Thank you in advance!

`describe('', () => { const disclaimerTextField = LandingPageSubMenu.DISCLAIMER.fields[0] const mockCustomOnChange = jest.fn()

const props = { field: disclaimerTextField, value: '', customOnChange: mockCustomOnChange, registerField: { ref: jest.fn() } }

test('renders', async () => { render(<RichTextEditor {...props} />)

expect(screen.getByTestId('sidenavfield__richtexteditor')).toBeInTheDocument()

}) })`