如何测试react-dropzone的文件上传功能

时间:2017-11-07 21:03:28

标签: reactjs enzyme react-dropzone

我想测试我的反应dropzone onDrop方法,这是我到目前为止所尝试的。

describe("RoadOrders", () => {
  let props;
  let mountedRoadOrders;
  const roadOrders = () => {
    if (!mountedRoadOrders) {
      mountedRoadOrders = mount(
        <MuiThemeProvider muiTheme={getMuiTheme()}>
          <Provider store={store}>
          <RoadOrders {...props} />
          </Provider>
        </MuiThemeProvider>
      );
    }
    return mountedRoadOrders;
  }

  beforeEach(() => {
    props = {};
    mountedRoadOrders = undefined;
  });

  describe("when dropped file", () => {
    beforeEach(() => {
      props.uploadFiles = undefined;
    });

    it("should upload that file to firebase", () => {
      const uploadFiles = roadOrders().find("Dropzone");
      uploadFiles.simulate('drop', {
        target: {
          files: [
            'a.jpg',
            'b.jpg',
            'c.jpg'
          ]
        }
      })
      expect(roadOrders()).toBe(1);
    });
  });
});

似乎onDrop功能确实已触发,但文件未成功上传到云端。如何测试文件上传功能并检查服务器的回调以查看它们是否已传递到服务器?

0 个答案:

没有答案