How to use the jest-mock-axios.post 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
onChange={onChange}
      />
    );
    const dropzone = getDropzoneForFileType(wrapper, 2);

    const file1 = {type: 'pdf', name: 'test.pdf'};

    // simulate actual "drop" event
    await act(async () => {
      dropzone.simulate('drop', createDtWithFiles([file1]));
    });

    const mockDispatch = React.mockDispatches[0];

    // the upload endpoint is properly called
    expect(mockAxios.post).toHaveBeenCalledWith(
      'http://upload/endpoint',
      expect.toContainFile(file1),
      expect.anything()
    );

    // the internal state is updated
    expect(mockDispatch).toHaveBeenCalledWith(
      expect.objectContaining({type: actions.START_UPLOADS})
    );

    expect(onChange).not.toHaveBeenCalled();

    await act(async () => {
      mockAxios.mockResponse(
        {
          data: {