@@ -9,14 +9,15 @@ const readFileSync = require('node:fs').readFileSync
9
9
const resolve = require ( 'node:path' ) . resolve
10
10
11
11
test ( 'swagger route returns yaml' , async ( t ) => {
12
+ t . plan ( 3 )
13
+
12
14
const config = {
13
15
mode : 'static' ,
14
16
specification : {
15
17
path : './examples/example-static-specification.yaml'
16
18
}
17
19
}
18
20
19
- t . plan ( 3 )
20
21
const fastify = Fastify ( )
21
22
await fastify . register ( fastifySwagger , config )
22
23
await fastify . register ( fastifySwaggerUi )
@@ -34,14 +35,15 @@ test('swagger route returns yaml', async (t) => {
34
35
} )
35
36
36
37
test ( 'swagger route returns json' , async ( t ) => {
38
+ t . plan ( 3 )
39
+
37
40
const config = {
38
41
mode : 'static' ,
39
42
specification : {
40
43
path : './examples/example-static-specification.json'
41
44
}
42
45
}
43
46
44
- t . plan ( 3 )
45
47
const fastify = Fastify ( )
46
48
await fastify . register ( fastifySwagger , config )
47
49
await fastify . register ( fastifySwaggerUi )
@@ -59,6 +61,8 @@ test('swagger route returns json', async (t) => {
59
61
} )
60
62
61
63
test ( 'postProcessor works, swagger route returns updated yaml' , async ( t ) => {
64
+ t . plan ( 4 )
65
+
62
66
const config = {
63
67
mode : 'static' ,
64
68
specification : {
@@ -70,7 +74,6 @@ test('postProcessor works, swagger route returns updated yaml', async (t) => {
70
74
}
71
75
}
72
76
73
- t . plan ( 4 )
74
77
const fastify = Fastify ( )
75
78
await fastify . register ( fastifySwagger , config )
76
79
await fastify . register ( fastifySwaggerUi )
@@ -89,6 +92,8 @@ test('postProcessor works, swagger route returns updated yaml', async (t) => {
89
92
} )
90
93
91
94
test ( 'swagger route returns explicitly passed doc' , async ( t ) => {
95
+ t . plan ( 2 )
96
+
92
97
const document = {
93
98
info : {
94
99
title : 'Test swagger' ,
@@ -104,7 +109,6 @@ test('swagger route returns explicitly passed doc', async (t) => {
104
109
}
105
110
}
106
111
107
- t . plan ( 2 )
108
112
const fastify = Fastify ( )
109
113
await fastify . register ( fastifySwagger , config )
110
114
@@ -120,6 +124,8 @@ test('swagger route returns explicitly passed doc', async (t) => {
120
124
} )
121
125
122
126
test ( '/documentation/:file should serve static file from the location of main specification file' , async ( t ) => {
127
+ t . plan ( 4 )
128
+
123
129
const config = {
124
130
mode : 'static' ,
125
131
specification : {
@@ -131,7 +137,6 @@ test('/documentation/:file should serve static file from the location of main sp
131
137
baseDir : resolve ( __dirname , '..' , 'examples' )
132
138
}
133
139
134
- t . plan ( 4 )
135
140
const fastify = Fastify ( )
136
141
await fastify . register ( fastifySwagger , config )
137
142
await fastify . register ( fastifySwaggerUi , uiConfig )
@@ -172,14 +177,15 @@ test('/documentation/:file should serve static file from the location of main sp
172
177
} )
173
178
174
179
test ( '/documentation/non-existing-file calls custom NotFoundHandler' , async ( t ) => {
180
+ t . plan ( 1 )
181
+
175
182
const config = {
176
183
mode : 'static' ,
177
184
specification : {
178
185
path : './examples/example-static-specification.yaml'
179
186
}
180
187
}
181
188
182
- t . plan ( 1 )
183
189
const fastify = Fastify ( )
184
190
await fastify . register ( fastifySwagger , config )
185
191
await fastify . register ( fastifySwaggerUi )
@@ -196,6 +202,8 @@ test('/documentation/non-existing-file calls custom NotFoundHandler', async (t)
196
202
} )
197
203
198
204
test ( '/documentation/:file should be served from custom location' , async ( t ) => {
205
+ t . plan ( 2 )
206
+
199
207
const config = {
200
208
mode : 'static' ,
201
209
specification : {
@@ -208,7 +216,6 @@ test('/documentation/:file should be served from custom location', async (t) =>
208
216
baseDir : resolve ( __dirname , '..' , 'static' )
209
217
}
210
218
211
- t . plan ( 2 )
212
219
const fastify = Fastify ( )
213
220
await fastify . register ( fastifySwagger , config )
214
221
await fastify . register ( fastifySwaggerUi , uiConfig )
@@ -227,6 +234,8 @@ test('/documentation/:file should be served from custom location', async (t) =>
227
234
} )
228
235
229
236
test ( '/documentation/:file should be served from custom location with trailing slash(es)' , async ( t ) => {
237
+ t . plan ( 2 )
238
+
230
239
const config = {
231
240
mode : 'static' ,
232
241
specification : {
@@ -238,7 +247,6 @@ test('/documentation/:file should be served from custom location with trailing s
238
247
baseDir : resolve ( __dirname , '..' , 'static' ) + '/'
239
248
}
240
249
241
- t . plan ( 2 )
242
250
const fastify = Fastify ( )
243
251
await fastify . register ( fastifySwagger , config )
244
252
await fastify . register ( fastifySwaggerUi , uiConfig )
@@ -256,14 +264,15 @@ test('/documentation/:file should be served from custom location with trailing s
256
264
} )
257
265
258
266
test ( '/documentation/yaml returns cache.swaggerString on second request in static mode' , async ( t ) => {
267
+ t . plan ( 6 )
268
+
259
269
const config = {
260
270
mode : 'static' ,
261
271
specification : {
262
272
path : './examples/example-static-specification.yaml'
263
273
}
264
274
}
265
275
266
- t . plan ( 6 )
267
276
const fastify = Fastify ( )
268
277
await fastify . register ( fastifySwagger , config )
269
278
await fastify . register ( fastifySwaggerUi )
@@ -294,14 +303,15 @@ test('/documentation/yaml returns cache.swaggerString on second request in stati
294
303
} )
295
304
296
305
test ( '/documentation/json returns cache.swaggerObject on second request in static mode' , async ( t ) => {
306
+ t . plan ( 6 )
307
+
297
308
const config = {
298
309
mode : 'static' ,
299
310
specification : {
300
311
path : './examples/example-static-specification.json'
301
312
}
302
313
}
303
314
304
- t . plan ( 6 )
305
315
const fastify = Fastify ( )
306
316
await fastify . register ( fastifySwagger , config )
307
317
await fastify . register ( fastifySwaggerUi )
@@ -330,13 +340,14 @@ test('/documentation/json returns cache.swaggerObject on second request in stati
330
340
} )
331
341
332
342
test ( '/documentation/yaml returns cache.swaggerString on second request in dynamic mode' , async ( t ) => {
343
+ t . plan ( 6 )
344
+
333
345
const config = {
334
346
specification : {
335
347
path : './examples/example-static-specification.yaml'
336
348
}
337
349
}
338
350
339
- t . plan ( 6 )
340
351
const fastify = Fastify ( )
341
352
await fastify . register ( fastifySwagger , config )
342
353
await fastify . register ( fastifySwaggerUi )
@@ -367,13 +378,14 @@ test('/documentation/yaml returns cache.swaggerString on second request in dynam
367
378
} )
368
379
369
380
test ( '/documentation/json returns cache.swaggerObject on second request in dynamic mode' , async ( t ) => {
381
+ t . plan ( 6 )
382
+
370
383
const config = {
371
384
specification : {
372
385
path : './examples/example-static-specification.json'
373
386
}
374
387
}
375
388
376
- t . plan ( 6 )
377
389
const fastify = Fastify ( )
378
390
await fastify . register ( fastifySwagger , config )
379
391
await fastify . register ( fastifySwaggerUi )
0 commit comments