Skip to content

Commit 16e8e37

Browse files
committed
pass invalid header to close stream test
1 parent fc28379 commit 16e8e37

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ test('should not compress on missing header', t => {
146146
})
147147
})
148148

149-
test('Should not compress on missing header', t => {
149+
test('Should close the stream', t => {
150150
t.plan(3)
151151
const fastify = Fastify()
152152
fastify.register(compressPlugin, { global: false })
@@ -159,10 +159,18 @@ test('Should not compress on missing header', t => {
159159

160160
fastify.inject({
161161
url: '/',
162-
method: 'GET'
162+
method: 'GET',
163+
headers: {
164+
'accept-encoding': 'compress'
165+
}
163166
}, res => {
164-
t.strictEqual(res.statusCode, 200)
165-
t.notOk(res.headers['content-encoding'])
167+
const payload = JSON.parse(res.payload)
168+
t.strictEqual(res.statusCode, 406)
169+
t.deepEqual({
170+
error: 'Not Acceptable',
171+
message: 'Unsupported encoding',
172+
statusCode: 406
173+
}, payload)
166174
})
167175
})
168176

0 commit comments

Comments
 (0)