@@ -15,7 +15,8 @@ test('pretty print - static routes', t => {
1515 fastify . ready ( ( ) => {
1616 const tree = fastify . printRoutes ( )
1717
18- const expected = `└── /
18+ const expected = `\
19+ └── /
1920 ├── test (GET)
2021 │ └── /hello (GET)
2122 └── hello/world (GET)
@@ -37,10 +38,13 @@ test('pretty print - parametric routes', t => {
3738 fastify . ready ( ( ) => {
3839 const tree = fastify . printRoutes ( )
3940
40- const expected = `└── /
41+ const expected = `\
42+ └── /
4143 ├── test (GET)
42- │ └── /:hello (GET)
43- └── hello/:world (GET)
44+ │ └── /
45+ │ └── :hello (GET)
46+ └── hello/
47+ └── :world (GET)
4448`
4549
4650 t . equal ( typeof tree , 'string' )
@@ -60,11 +64,12 @@ test('pretty print - mixed parametric routes', t => {
6064 fastify . ready ( ( ) => {
6165 const tree = fastify . printRoutes ( )
6266
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)
6873`
6974
7075 t . equal ( typeof tree , 'string' )
@@ -83,10 +88,13 @@ test('pretty print - wildcard routes', t => {
8388 fastify . ready ( ( ) => {
8489 const tree = fastify . printRoutes ( )
8590
86- const expected = `└── /
91+ const expected = `\
92+ └── /
8793 ├── test (GET)
88- │ └── /* (GET)
89- └── hello/* (GET)
94+ │ └── /
95+ │ └── * (GET)
96+ └── hello/
97+ └── * (GET)
9098`
9199
92100 t . equal ( typeof tree , 'string' )
@@ -134,17 +142,15 @@ test('pretty print - commonPrefix', t => {
134142 const radixTree = fastify . printRoutes ( )
135143 const flatTree = fastify . printRoutes ( { commonPrefix : false } )
136144
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)
144150`
145- const flatExpected = `└── / (-)
146- ├── helicopter (GET, HEAD)
147- └── hello (GET, HEAD, PUT )
151+ const flatExpected = `\
152+ ├── /hello (GET, HEAD, PUT )
153+ └── /helicopter (GET, HEAD)
148154`
149155 t . equal ( typeof radixTree , 'string' )
150156 t . equal ( typeof flatTree , 'string' )
@@ -170,49 +176,64 @@ test('pretty print - includeMeta, includeHooks', t => {
170176 const flatTree = fastify . printRoutes ( { commonPrefix : false , includeHooks : true , includeMeta : [ 'errorHandler' ] } )
171177 const hooksOnly = fastify . printRoutes ( { commonPrefix : false , includeHooks : true } )
172178
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()"
197200`
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()"
207220`
208221
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()"]
216237`
217238 t . equal ( typeof radixTree , 'string' )
218239 t . equal ( typeof flatTree , 'string' )
0 commit comments