@@ -15,7 +15,8 @@ test('pretty print - static routes', t => {
15
15
fastify . ready ( ( ) => {
16
16
const tree = fastify . printRoutes ( )
17
17
18
- const expected = `└── /
18
+ const expected = `\
19
+ └── /
19
20
├── test (GET)
20
21
│ └── /hello (GET)
21
22
└── hello/world (GET)
@@ -37,10 +38,13 @@ test('pretty print - parametric routes', t => {
37
38
fastify . ready ( ( ) => {
38
39
const tree = fastify . printRoutes ( )
39
40
40
- const expected = `└── /
41
+ const expected = `\
42
+ └── /
41
43
├── test (GET)
42
- │ └── /:hello (GET)
43
- └── hello/:world (GET)
44
+ │ └── /
45
+ │ └── :hello (GET)
46
+ └── hello/
47
+ └── :world (GET)
44
48
`
45
49
46
50
t . equal ( typeof tree , 'string' )
@@ -60,11 +64,12 @@ test('pretty print - mixed parametric routes', t => {
60
64
fastify . ready ( ( ) => {
61
65
const tree = fastify . printRoutes ( )
62
66
63
- const expected = `└── /test (GET)
64
- └── /
65
- └── :hello (GET)
66
- :hello (POST)
67
- └── /world (GET)
67
+ const expected = `\
68
+ └── /
69
+ └── test (GET)
70
+ └── /
71
+ └── :hello (GET, POST)
72
+ └── /world (GET)
68
73
`
69
74
70
75
t . equal ( typeof tree , 'string' )
@@ -83,10 +88,13 @@ test('pretty print - wildcard routes', t => {
83
88
fastify . ready ( ( ) => {
84
89
const tree = fastify . printRoutes ( )
85
90
86
- const expected = `└── /
91
+ const expected = `\
92
+ └── /
87
93
├── test (GET)
88
- │ └── /* (GET)
89
- └── hello/* (GET)
94
+ │ └── /
95
+ │ └── * (GET)
96
+ └── hello/
97
+ └── * (GET)
90
98
`
91
99
92
100
t . equal ( typeof tree , 'string' )
@@ -134,17 +142,15 @@ test('pretty print - commonPrefix', t => {
134
142
const radixTree = fastify . printRoutes ( )
135
143
const flatTree = fastify . printRoutes ( { commonPrefix : false } )
136
144
137
- const radixExpected = `└── /
138
- ├── hel
139
- │ ├── lo (GET)
140
- │ │ lo (HEAD)
141
- │ └── icopter (GET)
142
- │ icopter (HEAD)
143
- └── hello (PUT)
145
+ const radixExpected = `\
146
+ └── /
147
+ └── hel
148
+ ├── lo (GET, HEAD, PUT)
149
+ └── icopter (GET, HEAD)
144
150
`
145
- const flatExpected = `└── / (-)
146
- ├── helicopter (GET, HEAD)
147
- └── hello (GET, HEAD, PUT )
151
+ const flatExpected = `\
152
+ ├── /hello (GET, HEAD, PUT )
153
+ └── /helicopter (GET, HEAD)
148
154
`
149
155
t . equal ( typeof radixTree , 'string' )
150
156
t . equal ( typeof flatTree , 'string' )
@@ -170,49 +176,64 @@ test('pretty print - includeMeta, includeHooks', t => {
170
176
const flatTree = fastify . printRoutes ( { commonPrefix : false , includeHooks : true , includeMeta : [ 'errorHandler' ] } )
171
177
const hooksOnly = fastify . printRoutes ( { commonPrefix : false , includeHooks : true } )
172
178
173
- const radixExpected = `└── /
174
- ├── hel
175
- │ ├── lo (GET)
176
- │ │ • (onTimeout) ["onTimeout()"]
177
- │ │ • (onRequest) ["anonymous()"]
178
- │ │ • (errorHandler) "defaultErrorHandler()"
179
- │ │ lo (HEAD)
180
- │ │ • (onTimeout) ["onTimeout()"]
181
- │ │ • (onRequest) ["anonymous()"]
182
- │ │ • (onSend) ["headRouteOnSendHandler()"]
183
- │ │ • (errorHandler) "defaultErrorHandler()"
184
- │ └── icopter (GET)
185
- │ • (onTimeout) ["onTimeout()"]
186
- │ • (onRequest) ["anonymous()"]
187
- │ • (errorHandler) "defaultErrorHandler()"
188
- │ icopter (HEAD)
189
- │ • (onTimeout) ["onTimeout()"]
190
- │ • (onRequest) ["anonymous()"]
191
- │ • (onSend) ["headRouteOnSendHandler()"]
192
- │ • (errorHandler) "defaultErrorHandler()"
193
- └── hello (PUT)
194
- • (onTimeout) ["onTimeout()"]
195
- • (onRequest) ["anonymous()"]
196
- • (errorHandler) "defaultErrorHandler()"
179
+ const radixExpected = `\
180
+ └── /
181
+ └── hel
182
+ ├── lo (GET, PUT)
183
+ │ • (onTimeout) ["onTimeout()"]
184
+ │ • (onRequest) ["anonymous()"]
185
+ │ • (errorHandler) "defaultErrorHandler()"
186
+ │ lo (HEAD)
187
+ │ • (onTimeout) ["onTimeout()"]
188
+ │ • (onRequest) ["anonymous()"]
189
+ │ • (onSend) ["headRouteOnSendHandler()"]
190
+ │ • (errorHandler) "defaultErrorHandler()"
191
+ └── icopter (GET)
192
+ • (onTimeout) ["onTimeout()"]
193
+ • (onRequest) ["anonymous()"]
194
+ • (errorHandler) "defaultErrorHandler()"
195
+ icopter (HEAD)
196
+ • (onTimeout) ["onTimeout()"]
197
+ • (onRequest) ["anonymous()"]
198
+ • (onSend) ["headRouteOnSendHandler()"]
199
+ • (errorHandler) "defaultErrorHandler()"
197
200
`
198
- const flatExpected = `└── / (-)
199
- ├── helicopter (GET, HEAD)
200
- │ • (onTimeout) ["onTimeout()"]
201
- │ • (onRequest) ["anonymous()"]
202
- │ • (errorHandler) "defaultErrorHandler()"
203
- └── hello (GET, HEAD, PUT)
204
- • (onTimeout) ["onTimeout()"]
205
- • (onRequest) ["anonymous()"]
206
- • (errorHandler) "defaultErrorHandler()"
201
+ const flatExpected = `\
202
+ ├── /hello (GET, PUT)
203
+ │ • (onTimeout) ["onTimeout()"]
204
+ │ • (onRequest) ["anonymous()"]
205
+ │ • (errorHandler) "defaultErrorHandler()"
206
+ │ /hello (HEAD)
207
+ │ • (onTimeout) ["onTimeout()"]
208
+ │ • (onRequest) ["anonymous()"]
209
+ │ • (onSend) ["headRouteOnSendHandler()"]
210
+ │ • (errorHandler) "defaultErrorHandler()"
211
+ └── /helicopter (GET)
212
+ • (onTimeout) ["onTimeout()"]
213
+ • (onRequest) ["anonymous()"]
214
+ • (errorHandler) "defaultErrorHandler()"
215
+ /helicopter (HEAD)
216
+ • (onTimeout) ["onTimeout()"]
217
+ • (onRequest) ["anonymous()"]
218
+ • (onSend) ["headRouteOnSendHandler()"]
219
+ • (errorHandler) "defaultErrorHandler()"
207
220
`
208
221
209
- const hooksOnlyExpected = `└── / (-)
210
- ├── helicopter (GET, HEAD)
211
- │ • (onTimeout) ["onTimeout()"]
212
- │ • (onRequest) ["anonymous()"]
213
- └── hello (GET, HEAD, PUT)
214
- • (onTimeout) ["onTimeout()"]
215
- • (onRequest) ["anonymous()"]
222
+ const hooksOnlyExpected = `\
223
+ ├── /hello (GET, PUT)
224
+ │ • (onTimeout) ["onTimeout()"]
225
+ │ • (onRequest) ["anonymous()"]
226
+ │ /hello (HEAD)
227
+ │ • (onTimeout) ["onTimeout()"]
228
+ │ • (onRequest) ["anonymous()"]
229
+ │ • (onSend) ["headRouteOnSendHandler()"]
230
+ └── /helicopter (GET)
231
+ • (onTimeout) ["onTimeout()"]
232
+ • (onRequest) ["anonymous()"]
233
+ /helicopter (HEAD)
234
+ • (onTimeout) ["onTimeout()"]
235
+ • (onRequest) ["anonymous()"]
236
+ • (onSend) ["headRouteOnSendHandler()"]
216
237
`
217
238
t . equal ( typeof radixTree , 'string' )
218
239
t . equal ( typeof flatTree , 'string' )
0 commit comments