react-draft-wysiwyg icon indicating copy to clipboard operation
react-draft-wysiwyg copied to clipboard

Use a function to generate an ID if you need to

Open sontek opened this issue 7 years ago • 3 comments

I can't use react snapshots when testing my use of the WYSIWYG editor because of:

https://github.com/jpuri/react-draft-wysiwyg/blob/9be932d1a00f26468aa349b0118f310ba212f0b7/src/Editor/index.js#L103

If you use a function, then I could target it and mock it.

sontek avatar Nov 29 '17 20:11 sontek

Right now I'm doing:

    beforeEach(
        () => {
            StyleSheetTestUtils.suppressStyleInjection();
            Math.random = jest.fn(() => 123);
        }
    );

which I don't like, because I do use Math.random in other places.

sontek avatar Nov 29 '17 20:11 sontek

Hey @sontek , can you try to pass wrapperId and check, that should work.

jpuri avatar Dec 09 '17 16:12 jpuri

Hey @sontek I know its been too late to comment here Just commenting for helping others

If snapshots are keep updating, as because of wrapper ID is keep updating. So just provide wrapperID prop to the react-draft-WYSIWYG Editor as

<Editor wrapperID="some-id" in the main component of react-draft-WYSIWYG

aneeq-dev avatar Jan 29 '24 09:01 aneeq-dev