如何检查多个电话上的多个参数以寻找开玩笑的间谍?
2022-08-30 04:52:30
我在 React 组件中有以下函数:
onUploadStart(file, xhr, formData) {
formData.append('filename', file.name);
formData.append('mimeType', file.type);
}
这是我的测试,至少可以调用间谍:
const formData = { append: jest.fn() };
const file = { name: 'someFileName', type: 'someMimeType' };
eventHandlers.onUploadStart(file, null, formData);
expect(formData.append).toHaveBeenCalledWith(
['mimeType', 'someMimeType'],
['fileName', 'someFileName']
);
但是,断言不起作用:
Expected mock function to have been called with:
[["mimeType", "someMimeType"], ["fileName", "someFileName"]]
But it was called with:
["mimeType", "someMimeType"], ["filename", "someFileName"]
正确的使用方法是什么?toHaveBeenCalledWith