我想测试我的 react 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 功能,但文件没有成功上传到云端。如何测试文件上传功能并检查服务器的回调以查看它们是否已传递到服务器?