Skip to content

Commit

Permalink
Bind windows appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
zellwk committed Sep 20, 2022
1 parent f60dbf0 commit d5983f7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"name": "zl-fetch",
"version": "4.0.0",
"description": "A library that makes the Fetch API easy to use",
"main": "src/index.js",
"type": "module",
"files": ["src"],
"exports": {
".": { "import": "./src/index.js" },
"./*": "./src/*"
},
"keywords": ["fetch", "javascript", "browser", "nodejs", "ajax"],
"repository": "https://github.com/zellwk/zl-fetch",
"scripts": {
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ export async function getFetch () {
const f = await import('node-fetch')
return {
fetch: f.default,
Headers: f.Headers,
Request: f.Request
Headers: f.Headers
}
} else {
return {
fetch,
Headers,
Request
fetch: window.fetch.bind(window),
Headers: window.Headers
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/browser.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @vitest-environment jsdom
import { beforeEach, afterEach, describe, expect, it } from 'vitest'
import { beforeEach, afterEach } from 'vitest'
import { setup, teardown } from './helpers/setup.js'
import integrationTests from './helpers/integration-tests.js'

Expand Down
4 changes: 2 additions & 2 deletions test/helpers/integration-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function tests (environment) {
expect(error.body.message).toBe('An error message')
})

it(`Returns Error`, async ({ endpoint }) => {
it('Returns Error', async ({ endpoint }) => {
const { response, error } = await zlFetch(`${endpoint}/json-error`, {
returnError: true
})
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function tests (environment) {
auth: '12345'
})
const authHeader = debug.headers.authorization
expect(authHeader).toBe(`Bearer 12345`)
expect(authHeader).toBe('Bearer 12345')
})
})
}
2 changes: 1 addition & 1 deletion test/node.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeEach, afterEach, describe, expect, it } from 'vitest'
import { beforeEach, afterEach } from 'vitest'
import { setup, teardown } from './helpers/setup.js'
import integrationTests from './helpers/integration-tests.js'

Expand Down

0 comments on commit d5983f7

Please sign in to comment.