Skip to content

Commit fe81224

Browse files
Uzlopakcrysmags
authored andcommitted
chore: migrate a batch of tests to node test runner (nodejs#2740)
1 parent 938e7b4 commit fe81224

File tree

6 files changed

+365
-276
lines changed

6 files changed

+365
-276
lines changed

test/redirect-pipeline.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

3-
const t = require('tap')
3+
const { tspl } = require('@matteo.collina/tspl')
4+
const { test } = require('node:test')
45
const { pipeline: undiciPipeline } = require('..')
56
const { pipeline: streamPipelineCb } = require('node:stream')
67
const { promisify } = require('node:util')
@@ -9,42 +10,42 @@ const { startRedirectingServer } = require('./utils/redirecting-servers')
910

1011
const streamPipeline = promisify(streamPipelineCb)
1112

12-
t.test('should not follow redirection by default if not using RedirectAgent', async t => {
13-
t.plan(3)
13+
test('should not follow redirection by default if not using RedirectAgent', async t => {
14+
t = tspl(t, { plan: 3 })
1415

1516
const body = []
16-
const serverRoot = await startRedirectingServer(t)
17+
const serverRoot = await startRedirectingServer()
1718

1819
await streamPipeline(
1920
createReadable('REQUEST'),
2021
undiciPipeline(`http://${serverRoot}/`, {}, ({ statusCode, headers, body }) => {
21-
t.equal(statusCode, 302)
22-
t.equal(headers.location, `http://${serverRoot}/302/1`)
22+
t.strictEqual(statusCode, 302)
23+
t.strictEqual(headers.location, `http://${serverRoot}/302/1`)
2324

2425
return body
2526
}),
2627
createWritable(body)
2728
)
2829

29-
t.equal(body.length, 0)
30+
t.strictEqual(body.length, 0)
3031
})
3132

32-
t.test('should not follow redirects when using RedirectAgent within pipeline', async t => {
33-
t.plan(3)
33+
test('should not follow redirects when using RedirectAgent within pipeline', async t => {
34+
t = tspl(t, { plan: 3 })
3435

3536
const body = []
36-
const serverRoot = await startRedirectingServer(t)
37+
const serverRoot = await startRedirectingServer()
3738

3839
await streamPipeline(
3940
createReadable('REQUEST'),
4041
undiciPipeline(`http://${serverRoot}/`, { maxRedirections: 1 }, ({ statusCode, headers, body }) => {
41-
t.equal(statusCode, 302)
42-
t.equal(headers.location, `http://${serverRoot}/302/1`)
42+
t.strictEqual(statusCode, 302)
43+
t.strictEqual(headers.location, `http://${serverRoot}/302/1`)
4344

4445
return body
4546
}),
4647
createWritable(body)
4748
)
4849

49-
t.equal(body.length, 0)
50+
t.strictEqual(body.length, 0)
5051
})

test/redirect-relative.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
'use strict'
22

3-
const t = require('tap')
3+
const { tspl } = require('@matteo.collina/tspl')
4+
const { test } = require('node:test')
45
const { request } = require('..')
56
const {
67
startRedirectingWithRelativePath
78
} = require('./utils/redirecting-servers')
89

9-
t.test('should redirect to relative URL according to RFC 7231', async t => {
10-
t.plan(2)
10+
test('should redirect to relative URL according to RFC 7231', async t => {
11+
t = tspl(t, { plan: 2 })
1112

12-
const server = await startRedirectingWithRelativePath(t)
13+
const server = await startRedirectingWithRelativePath()
1314

1415
const { statusCode, body } = await request(`http://${server}`, {
1516
maxRedirections: 3
1617
})
1718

1819
const finalPath = await body.text()
1920

20-
t.equal(statusCode, 200)
21-
t.equal(finalPath, '/absolute/b')
21+
t.strictEqual(statusCode, 200)
22+
t.strictEqual(finalPath, '/absolute/b')
2223
})

0 commit comments

Comments
 (0)