diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 20:56:19 +0000 |
commit | 0b6210cd37b68b94252cb798598b12974a20e1c1 (patch) | |
tree | e371686554a877842d95aa94f100bee552ff2a8e /test/issue-2078.js | |
parent | Initial commit. (diff) | |
download | node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.tar.xz node-undici-0b6210cd37b68b94252cb798598b12974a20e1c1.zip |
Adding upstream version 5.28.2+dfsg1+~cs23.11.12.3.upstream/5.28.2+dfsg1+_cs23.11.12.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/issue-2078.js')
-rw-r--r-- | test/issue-2078.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/issue-2078.js b/test/issue-2078.js new file mode 100644 index 0000000..d3aa868 --- /dev/null +++ b/test/issue-2078.js @@ -0,0 +1,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')) +}) |