Skip to content

Commit

Permalink
Updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Feb 2, 2021
1 parent d1906c3 commit 0a6d9a2
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/context-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,55 @@ test('config with exposeHeadRoutes', t => {
t.deepEquals(JSON.parse(response.payload), { url: '/no-config', method: 'GET' })
})
})

test('config without exposeHeadRoutes', t => {
t.plan(9)
const fastify = Fastify({ exposeHeadRoutes: false })

fastify.get('/get', {
schema: schema.schema,
config: Object.assign({}, schema.config)
}, handler)

fastify.route({
method: 'GET',
url: '/route',
schema: schema.schema,
handler: handler,
config: Object.assign({}, schema.config)
})

fastify.route({
method: 'GET',
url: '/no-config',
schema: schema.schema,
handler: handler
})

fastify.inject({
method: 'GET',
url: '/get'
}, (err, response) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.deepEquals(JSON.parse(response.payload), Object.assign({ url: '/get', method: 'GET' }, schema.config))
})

fastify.inject({
method: 'GET',
url: '/route'
}, (err, response) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.deepEquals(JSON.parse(response.payload), Object.assign({ url: '/route', method: 'GET' }, schema.config))
})

fastify.inject({
method: 'GET',
url: '/no-config'
}, (err, response) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.deepEquals(JSON.parse(response.payload), { url: '/no-config', method: 'GET' })
})
})

0 comments on commit 0a6d9a2

Please sign in to comment.