mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
1f92d64ea3
* chore: Update engines field * fix(deps): Remove node-fetch * feat(polyfills): Remove node-fetch for undici * feat(webapi): Remove node-fetch from the webapis polyfills for undici * feat(core): Remove node-fetch for undici in Astro core * feat(telemetry): Remove node-fetch for undici * feat(node): Remove node-fetch for undici in node integration * feat(vercel): Remove node-fetch for undici in Vercel integration * chore: update lockfile * chore: update lockfile * chore: changeset * fix(set): Fix set directives not streaming correctly on Node 16 * Try another approach * Debugging * Debug fetch * Use global fetch if there is one * changeset for lit * Remove web-streams-polyfill * Remove web-streams-polyfill license note * Update .changeset/stupid-wolves-explain.md Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com> Co-authored-by: Matthew Phillips <matthew@skypack.dev> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
40 lines
851 B
JavaScript
40 lines
851 B
JavaScript
import { expect } from 'chai'
|
|
import { polyfill } from '../mod.js'
|
|
|
|
describe('Fetch', () => {
|
|
const target = {}
|
|
|
|
before(() => polyfill(target))
|
|
|
|
it('Fetch functionality', () => {
|
|
expect(target).to.have.property('fetch').that.is.a('function')
|
|
})
|
|
|
|
it('Fetch with https', async () => {
|
|
const { fetch } = target
|
|
|
|
const response = await fetch('https://api.openbrewerydb.org/breweries')
|
|
|
|
expect(response.constructor).to.equal(target.Response)
|
|
|
|
const json = await response.json()
|
|
|
|
expect(json).to.be.an('array')
|
|
})
|
|
|
|
it('Fetch with data', async () => {
|
|
const { fetch } = target
|
|
|
|
const jsonURI = `data:application/json,${encodeURIComponent(
|
|
JSON.stringify({
|
|
name: '@astrojs/webapi',
|
|
})
|
|
)}`
|
|
|
|
const response = await fetch(jsonURI)
|
|
|
|
const json = await response.json()
|
|
|
|
expect(json.name).to.equal('@astrojs/webapi')
|
|
})
|
|
})
|