I have a form with React Quill Text Editor. On submit I read the values from it. I wrote a unit test, to write something and check if the correct values are being sent. It goes like this.
const updatedText = "New updated text(November)";
fireEvent.change(document.querySelector('quill-editor'), {
target: { textContent: updatedText }
});
fireEvent.click(screen.getByRole("button", { name: "update-post" }));
await waitFor(() => {
expect(mockSocialPostUpdate).toHaveBeenCalledWith(
expect.objectContaining({ path: "/api/v1/social-posts/" }),
{ id: feeds[0]["profile"]["id"] },
{
id: 1,
text: expect.objectContaining({
insert: updatedText
}),
profileId: 1,
channelId: 1
}
);
});
I am spying the put method and using fireEvent.change. When I see what has been posted, it is still the old value. Is there any correct way to change it?