UNPKG

1.13 kBJavaScriptView Raw
1'use strict'
2
3const { test } = require('tap')
4const Fastify = require('..')
5
6test('should emit warning using genReqId prop in logger options', t => {
7 t.plan(1)
8
9 process.once('warning', warning => {
10 t.strictEqual(warning.message, "Using 'genReqId' in logger options is deprecated. Use fastify options instead. See: https://www.fastify.io/docs/latest/Server/#gen-request-id")
11 })
12
13 Fastify({ logger: { genReqId: 'test' } })
14})
15
16test('should emit warning if basePath prop is used', t => {
17 t.plan(1)
18
19 process.once('warning', warning => {
20 t.strictEqual(warning.message, 'basePath is deprecated. Use prefix instead. See: https://www.fastify.io/docs/latest/Server/#prefix')
21 })
22
23 const fastify = Fastify({ basePath: '/test' })
24 return fastify.basePath
25})
26
27test('should emit warning if preHandler is used', t => {
28 t.plan(1)
29
30 process.once('warning', warning => {
31 t.strictEqual(warning.message, 'The route option `beforeHandler` has been deprecated, use `preHandler` instead')
32 })
33
34 const fastify = Fastify()
35
36 fastify.setNotFoundHandler({
37 beforeHandler: (req, reply, done) => done()
38 }, () => {})
39})