Skip to content

Commit

Permalink
test: test urls fetching only if fetch is available
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoaxel committed Jan 27, 2024
1 parent 3e4068c commit 4904ccd
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/PDFMerger-browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ import { jest } from '@jest/globals'

import PDFMerger from '../browser'

/*
add a global `windows.fetch` to mock fetch
*/
global.window.fetch = jest.fn().mockImplementation((requestUrl) => {
return Promise.resolve(fetch(requestUrl))
})

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const FIXTURES_DIR = path.join(__dirname, 'fixtures')
const TMP_DIR = path.join(__dirname, 'tmp')
Expand Down Expand Up @@ -175,7 +168,8 @@ describe('PDFMerger for browser', () => {
expect(diff).toBeFalsy()
})

test('merge pdfs from urls', async () => {
const testIfFetch = typeof fetch !== 'undefined' ? test : test.skip
testIfFetch('merge pdfs from urls', async () => {
const merger = new PDFMerger()

await merger.add(
Expand Down

0 comments on commit 4904ccd

Please sign in to comment.