blob: d3aa868ef435f7da4d0a45b9d15b321d5292b67f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
'use strict'
const { test, skip } = require('tap')
const { nodeMajor, nodeMinor } = require('../lib/core/util')
const { MockAgent, getGlobalDispatcher, setGlobalDispatcher, fetch } = require('..')
if (nodeMajor < 16 || (nodeMajor === 16 && nodeMinor < 8)) {
skip('fetch is not supported in node < v16.8.0')
process.exit()
}
test('MockPool.reply headers are an object, not an array - issue #2078', async (t) => {
const global = getGlobalDispatcher()
const mockAgent = new MockAgent()
const mockPool = mockAgent.get('http://localhost')
t.teardown(() => setGlobalDispatcher(global))
setGlobalDispatcher(mockAgent)
mockPool.intercept({
path: '/foo',
method: 'GET'
}).reply((options) => {
t.ok(!Array.isArray(options.headers))
return { statusCode: 200 }
})
await t.resolves(fetch('http://localhost/foo'))
})
|