-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate a batch of tests to node test runner (#2738)
- Loading branch information
Showing
10 changed files
with
299 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const { tspl } = require('@matteo.collina/tspl') | ||
const { test, after } = require('node:test') | ||
const { MockAgent, getGlobalDispatcher, setGlobalDispatcher, fetch } = require('..') | ||
|
||
test('MockPool.reply headers are an object, not an array - issue #2078', async (t) => { | ||
t = tspl(t, { plan: 1 }) | ||
|
||
const global = getGlobalDispatcher() | ||
const mockAgent = new MockAgent() | ||
const mockPool = mockAgent.get('http://localhost') | ||
|
||
t.teardown(() => setGlobalDispatcher(global)) | ||
after(() => setGlobalDispatcher(global)) | ||
setGlobalDispatcher(mockAgent) | ||
|
||
mockPool.intercept({ | ||
path: '/foo', | ||
method: 'GET' | ||
}).reply((options) => { | ||
t.ok(!Array.isArray(options.headers)) | ||
t.strictEqual(Array.isArray(options.headers), false) | ||
|
||
return { statusCode: 200 } | ||
}) | ||
|
||
await t.resolves(fetch('http://localhost/foo')) | ||
await fetch('http://localhost/foo') | ||
|
||
await t.completed | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.