This reverts commit 4ce7fc6987, to take
more time to address PR comments
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { downloadFile } from '../downloadFile';
|
||||
|
||||
// Mock fetch
|
||||
global.fetch = jest.fn(() =>
|
||||
Promise.resolve({
|
||||
status: 200,
|
||||
@ -15,10 +16,13 @@ window.URL.revokeObjectURL = jest.fn();
|
||||
// `global.fetch` and `window.fetch` are also undefined
|
||||
describe.skip('downloadFile', () => {
|
||||
it('should download a file', () => {
|
||||
// Call downloadFile
|
||||
downloadFile('url/to/file.pdf', 'file.pdf');
|
||||
|
||||
// Assert on fetch
|
||||
expect(fetch).toHaveBeenCalledWith('url/to/file.pdf');
|
||||
|
||||
// Assert on element creation
|
||||
const link = document.querySelector(
|
||||
'a[href="mock-url"][download="file.pdf"]',
|
||||
);
|
||||
@ -28,8 +32,10 @@ describe.skip('downloadFile', () => {
|
||||
// @ts-ignore
|
||||
expect(link?.style?.display).toBe('none');
|
||||
|
||||
// Assert on element click
|
||||
expect(link).toHaveBeenCalledTimes(1);
|
||||
|
||||
// Clean up mocks
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user