Skip to content

Commit 57ca3a5

Browse files
author
Mert Can Altin
committed
test: added for redirectionLimitReached
1 parent f737b2c commit 57ca3a5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/redirect-request.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,21 @@ for (const factory of [
255255
t.test('should follow a redirect chain up to the allowed number of times', async t => {
256256
const server = await startRedirectingServer(t)
257257

258+
const { statusCode, headers, body: bodyStream, context: { history } } = await request(t, server, undefined, `http://${server}/300`, {
259+
maxRedirections: 2
260+
})
261+
262+
const body = await bodyStream.text()
263+
264+
t.equal(statusCode, 300)
265+
t.equal(headers.location, `http://${server}/300/3`)
266+
t.same(history.map(x => x.toString()), [`http://${server}/300`, `http://${server}/300/1`, `http://${server}/300/2`])
267+
t.equal(body.length, 0)
268+
})
269+
270+
t.test('should follow a redirect chain up to the allowed number of times for redirectionLimitReached', async t => {
271+
const server = await startRedirectingServer(t)
272+
258273
try {
259274
const { statusCode, headers, body: bodyStream, context: { history } } = await request(t, server, undefined, `http://${server}/300`, {
260275
maxRedirections: 2

0 commit comments

Comments
 (0)