Skip to content

Commit

Permalink
Bump avvio to 7.1.1 and add a regression test (#2408)
Browse files Browse the repository at this point in the history
See: #2406
  • Loading branch information
mcollina committed Jul 14, 2020
1 parent 2495ba1 commit 733f535
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"dependencies": {
"abstract-logging": "^2.0.0",
"ajv": "^6.12.2",
"avvio": "^7.1.0",
"avvio": "^7.1.1",
"fast-json-stringify": "^2.2.1",
"fastify-error": "^0.1.0",
"find-my-way": "^3.0.0",
Expand Down
42 changes: 42 additions & 0 deletions test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,48 @@ test('nested plugins', t => {
})
})

test('nested plugins awaited', t => {
t.plan(5)

const fastify = Fastify()

t.tearDown(fastify.close.bind(fastify))

fastify.register(async function wrap (fastify, opts) {
await fastify.register(async function child1 (fastify, opts) {
fastify.get('/', function (req, reply) {
reply.send('I am child 1')
})
}, { prefix: '/child1' })

await fastify.register(async function child2 (fastify, opts) {
fastify.get('/', function (req, reply) {
reply.send('I am child 2')
})
}, { prefix: '/child2' })
}, { prefix: '/parent' })

fastify.listen(0, err => {
t.error(err)

sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port + '/parent/child1'
}, (err, response, body) => {
t.error(err)
t.deepEqual(body.toString(), 'I am child 1')
})

sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port + '/parent/child2'
}, (err, response, body) => {
t.error(err)
t.deepEqual(body.toString(), 'I am child 2')
})
})
})

test('plugin metadata - decorators', t => {
t.plan(1)
const fastify = Fastify()
Expand Down

0 comments on commit 733f535

Please sign in to comment.