How to use the jest-mock-axios.delete function in jest-mock-axios

To help you get started, weā€™ve selected a few jest-mock-axios examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github indico / indico / indico / modules / events / editing / client / js / __tests__ / FileManager.spec.jsx View on Github external
// replace the newly uploaded file
    const uuid = await uploadFile(dropzone, onChange, 'test2.pdf', 'pdf', 'newtest1.pdf');
    wrapper.update();
    const fileEntry = getFileEntryForFileType(wrapper, 2);
    checkFileEntry(fileEntry, 'test2.pdf', 'trash');

    // perform an undo - this needs to go back to an empty file list
    await act(async () => {
      fileEntry.find('FileAction').simulate('click');
      mockAxios.mockResponse(
        undefined,
        mockAxios.mustGetReqByUrl(`flask://files.delete_file/uuid=${uuid}`)
      );
    });
    expect(mockAxios.delete).toHaveBeenCalledWith(`flask://files.delete_file/uuid=${uuid}`);
    expect(onChange).toHaveBeenCalledWith({});
  });
github indico / indico / indico / modules / events / editing / client / js / __tests__ / FileManager.spec.jsx View on Github external
async function uploadFile(dropzone, onChange, name, type, deletedFile = null) {
  const uuid = await simulateFileUpload(dropzone, name, type);
  expect(onChange).toHaveBeenCalledWith({'2': [uuid]});
  if (deletedFile) {
    const deleteUrl = `flask://files.delete_file/uuid=${deletedFile}`;
    expect(mockAxios.delete).toHaveBeenCalledWith(deleteUrl);
    await act(async () => {
      mockAxios.mockResponse(undefined, mockAxios.mustGetReqByUrl(deleteUrl));
    });
  } else {
    expect(mockAxios.delete).not.toHaveBeenCalled();
  }
  onChange.mockClear();
  mockAxios.delete.mockClear();
  return uuid;
}