1 | 'use strict'
|
2 |
|
3 | const { test } = require('tap')
|
4 | const Fastify = require('..')
|
5 |
|
6 | test('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 |
|
16 | test('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 |
|
27 | test('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 | })
|