Skip to content

Commit

Permalink
tap18
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Apr 3, 2024
1 parent 11beb00 commit 230214e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
10 changes: 1 addition & 9 deletions .taprc
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
ts: false
jsx: false
flow: false

functions: 97
lines: 96
statements: 96
branches: 96

disable-coverage: true
files:
- test/**/*.test.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"snazzy": "^9.0.0",
"split2": "^4.2.0",
"standard": "^17.1.0",
"tap": "^16.3.10",
"tap": "^18.7.2",
"tsd": "^0.30.7"
},
"dependencies": {
Expand Down
15 changes: 6 additions & 9 deletions test/http2-http2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,23 @@ t.test('http2 -> http2', async (t) => {
http2: true,
https: certs
})

t.teardown(instance.close.bind(instance))

const target = Fastify({
http2: true
})

t.teardown(instance.close.bind(instance))
t.teardown(target.close.bind(target))

instance.get('/', (request, reply) => {
reply.from()
})
target.get('/', (request, reply) => {
t.pass('request proxied')
reply.code(404).header('x-my-header', 'hello!').send({
hello: 'world'
})
})

instance.get('/', (request, reply) => {
reply.from()
})

t.teardown(target.close.bind(target))

await target.listen({ port: 0 })

instance.register(From, {
Expand Down
8 changes: 5 additions & 3 deletions test/http2-invalid-base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const From = require('../index')
test('http2 invalid base', async (t) => {
const instance = Fastify()

await t.rejects(instance.register(From, {
http2: { requestTimeout: 100 }
}), new Error('Option base is required when http2 is true'))
t.throws(async () => {
await instance.register(From, {
http2: true
})
}, 'Option base is required when http2 is true')
})
10 changes: 6 additions & 4 deletions test/http2-unix-socket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ test('throw an error if http2 is used with a Unix socket destination', async t =

const instance = Fastify()

await t.rejects(instance.register(From, {
base: 'unix+http://localhost:1337',
http2: { requestTimeout: 100 }
}), new Error('Unix socket destination is not supported when http2 is true'))
t.throws(async () => {
await instance.register(From, {
base: 'unix+http://localhost:1337',
http2: { requestTimeout: 100 }
})
}, 'Unix socket destination is not supported when http2 is true')
})

0 comments on commit 230214e

Please sign in to comment.