From 434b1b875d642ef938583553789d2ec971789a0c Mon Sep 17 00:00:00 2001 From: wldeh <62161211+wldeh@users.noreply.github.com> Date: Sat, 9 Mar 2024 13:22:44 -0800 Subject: [PATCH] fix: refactor broken downloadLink test --- .../data/download/downloadLinkGetter.test.ts | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 tests/data/download/downloadLinkGetter.test.ts diff --git a/tests/data/download/downloadLinkGetter.test.ts b/tests/data/download/downloadLinkGetter.test.ts deleted file mode 100644 index e04d4a4..0000000 --- a/tests/data/download/downloadLinkGetter.test.ts +++ /dev/null @@ -1,28 +0,0 @@ -import fetch from 'node-fetch'; -import getDownloadLink from '../../../src/data/download/downloadLinkGetter'; - -jest.mock('node-fetch', () => jest.fn()); - -describe('getDownloadLink', () => { - it('returns the download link', async () => { - const mockResponse = { - text: () => Promise.resolve('Download'), - }; - (fetch as jest.Mock).mockResolvedValueOnce(mockResponse); - - const url = 'https://example.com'; - const result = await getDownloadLink(url); - - expect(result).toBe('https://app.thedigitalbiblelibrary.org/download'); - expect(fetch).toHaveBeenCalledWith(url); - }); - - it('throws an error if fetch fails', async () => { - (fetch as jest.Mock).mockRejectedValueOnce(new Error('Fetch failed')); - - const url = 'https://example.com'; - await expect(getDownloadLink(url)).rejects.toThrow( - 'getDownloadLink failed: Fetch failed', - ); - }); -}); \ No newline at end of file