0
votes

I'm new in testing.

I have this function that exports a file to .csv format. Please tell me how to test it through Jest?

export(response: AxiosResponse<Blob | MediaSource>) {
    const contentDisposition = response.headers['content-disposition'];

    if (contentDisposition) {
      const a = document.createElement('a');

      a.href = URL.createObjectURL(response.data);
      a.download = this.extractFilename(contentDisposition);

      a.click();

      return;
    }

    throw Error('Failed to extract content-disposition');
}