Skip to content

Commit

Permalink
test: refactor suite
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 committed Aug 23, 2023
1 parent 904f334 commit bbd1ffe
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/http2.js
Expand Up @@ -189,7 +189,10 @@ test('Should throw if bad maxConcurrentStreams has been pased', async t => {
})
t.fail()
} catch (error) {
t.equal(error.message, 'maxConcurrentStreams must be a possitive integer, greater than 0')
t.equal(
error.message,
'maxConcurrentStreams must be a possitive integer, greater than 0'
)
}

try {
Expand All @@ -200,7 +203,10 @@ test('Should throw if bad maxConcurrentStreams has been pased', async t => {
})
t.fail()
} catch (error) {
t.equal(error.message, 'maxConcurrentStreams must be a possitive integer, greater than 0')
t.equal(
error.message,
'maxConcurrentStreams must be a possitive integer, greater than 0'
)
}
})

Expand Down Expand Up @@ -643,15 +649,17 @@ test('Should handle h2 request with body (stream)', async t => {
t.equal(headers[':path'], '/')
t.equal(headers[':scheme'], 'https')

stream.on('data', chunk => requestChunks.push(chunk))

stream.respond({
'content-type': 'text/plain; charset=utf-8',
'x-custom-h2': headers['x-my-header'],
':status': 200
})

stream.end('hello h2!')

for await (const chunk of stream) {
requestChunks.push(chunk)
}
})

t.plan(8)
Expand All @@ -678,11 +686,9 @@ test('Should handle h2 request with body (stream)', async t => {
body: stream
})

response.body.on('data', chunk => {
for await (const chunk of response.body) {
responseBody.push(chunk)
})

await once(response.body, 'end')
}

t.equal(response.statusCode, 200)
t.equal(response.headers['content-type'], 'text/plain; charset=utf-8')
Expand Down

0 comments on commit bbd1ffe

Please sign in to comment.