反应羽毛笔笑话更改文本值

时间:2020-09-22 15:22:56

标签: reactjs jestjs react-quill

我有一个带有React Quill Text Editor的表单。在提交时,我从中读取了值。我编写了一个单元测试,以编写一些内容并检查是否发送了正确的值。就像这样。

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
        }
      );
    });

我正在监视put方法并使用fireEvent.change。当我看到已发布的内容时,它仍然是旧值。有什么正确的方法可以更改它吗?

0 个答案:

没有答案