I'm trying to simulate paste event with a JEST test on my react project.
I have an external component "App" witch contain the input field with "onPaste" event and I would like to test to past data and check the input value.
it("on past with small code", () => {
// Create new Security Code module
const wrapper = mount(<CodeVerification />);
const element = wrapper.find(".code-verification .code input");
const element1 = element.first();
element1.simulate("paste", { clipboardData: {value: "12"} });
});
In my component, i call clipboardData event :
const pasteDatas = pastEvent.clipboardData || window.clipboardData;
const paste = pasteDatas.getData("text");
When I execute my test, there is an error because
TypeError: pasteDatas.getData is not a function.
How can i mock clipboard event data and get input value in my JEST test ?
Thanks for yours responses.