@@ -6,6 +6,8 @@ const test = t.test
6
6
const fp = require ( '../plugin' )
7
7
const Fastify = require ( 'fastify' )
8
8
9
+ const pkg = require ( '../package.json' )
10
+
9
11
test ( 'fastify-plugin is a function' , t => {
10
12
t . plan ( 1 )
11
13
t . type ( fp , 'function' )
@@ -206,12 +208,12 @@ test('should check fastify dependency graph - plugin', t => {
206
208
const fastify = Fastify ( )
207
209
208
210
fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
209
- fastify : '4 .x' ,
211
+ fastify : '5 .x' ,
210
212
name : 'plugin1-name'
211
213
} ) )
212
214
213
215
fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
214
- fastify : '4 .x' ,
216
+ fastify : '5 .x' ,
215
217
name : 'test' ,
216
218
dependencies : [ 'plugin1-name' , 'plugin2-name' ]
217
219
} ) )
@@ -226,12 +228,12 @@ test('should check fastify dependency graph - decorate', t => {
226
228
const fastify = Fastify ( )
227
229
228
230
fastify . decorate ( 'plugin1' , fp ( ( fastify , opts , next ) => next ( ) , {
229
- fastify : '4 .x' ,
231
+ fastify : '5 .x' ,
230
232
name : 'plugin1-name'
231
233
} ) )
232
234
233
235
fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
234
- fastify : '4 .x' ,
236
+ fastify : '5 .x' ,
235
237
name : 'test' ,
236
238
decorators : { fastify : [ 'plugin1' , 'plugin2' ] }
237
239
} ) )
@@ -246,12 +248,12 @@ test('should check fastify dependency graph - decorateReply', t => {
246
248
const fastify = Fastify ( )
247
249
248
250
fastify . decorateReply ( 'plugin1' , fp ( ( fastify , opts , next ) => next ( ) , {
249
- fastify : '4 .x' ,
251
+ fastify : '5 .x' ,
250
252
name : 'plugin1-name'
251
253
} ) )
252
254
253
255
fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
254
- fastify : '4 .x' ,
256
+ fastify : '5 .x' ,
255
257
name : 'test' ,
256
258
decorators : { reply : [ 'plugin1' , 'plugin2' ] }
257
259
} ) )
@@ -311,20 +313,24 @@ test('should check dependencies when encapsulated', t => {
311
313
} )
312
314
} )
313
315
314
- test ( 'should check version when encapsulated' , t => {
315
- t . plan ( 1 )
316
- const fastify = Fastify ( )
316
+ test (
317
+ 'should check version when encapsulated' ,
318
+ { skip : / \d - .+ / . test ( pkg . devDependencies . fastify ) } ,
319
+ t => {
320
+ t . plan ( 1 )
321
+ const fastify = Fastify ( )
317
322
318
- fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
319
- name : 'test' ,
320
- fastify : '<=2.10.0' ,
321
- encapsulate : true
322
- } ) )
323
+ fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
324
+ name : 'test' ,
325
+ fastify : '<=2.10.0' ,
326
+ encapsulate : true
327
+ } ) )
323
328
324
- fastify . ready ( err => {
325
- t . match ( err . message , / f a s t i f y - p l u g i n : t e s t - e x p e c t e d ' < = 2 .1 0 .0 ' f a s t i f y v e r s i o n , ' \d .\d + .\d + ' i s i n s t a l l e d / )
326
- } )
327
- } )
329
+ fastify . ready ( err => {
330
+ t . match ( err . message , / f a s t i f y - p l u g i n : t e s t - e x p e c t e d ' < = 2 .1 0 .0 ' f a s t i f y v e r s i o n , ' \d .\d + .\d + ' i s i n s t a l l e d / )
331
+ } )
332
+ }
333
+ )
328
334
329
335
test ( 'should check decorators when encapsulated' , t => {
330
336
t . plan ( 1 )
@@ -333,7 +339,7 @@ test('should check decorators when encapsulated', t => {
333
339
fastify . decorate ( 'plugin1' , 'foo' )
334
340
335
341
fastify . register ( fp ( ( fastify , opts , next ) => next ( ) , {
336
- fastify : '4 .x' ,
342
+ fastify : '5 .x' ,
337
343
name : 'test' ,
338
344
encapsulate : true ,
339
345
decorators : { fastify : [ 'plugin1' , 'plugin2' ] }
@@ -352,14 +358,14 @@ test('plugin name when encapsulated', async t => {
352
358
} )
353
359
354
360
fastify . register ( fp ( getFn ( 'hello' ) , {
355
- fastify : '4 .x' ,
361
+ fastify : '5 .x' ,
356
362
name : 'hello' ,
357
363
encapsulate : true
358
364
} ) )
359
365
360
366
fastify . register ( function plugin ( fastify , opts , next ) {
361
367
fastify . register ( fp ( getFn ( 'deep' ) , {
362
- fastify : '4 .x' ,
368
+ fastify : '5 .x' ,
363
369
name : 'deep' ,
364
370
encapsulate : true
365
371
} ) )
@@ -368,25 +374,25 @@ test('plugin name when encapsulated', async t => {
368
374
t . equal ( fastify . pluginName , 'deep-deep' , 'should be deep-deep' )
369
375
370
376
fastify . register ( fp ( getFn ( 'deep-deep-deep' ) , {
371
- fastify : '4 .x' ,
377
+ fastify : '5 .x' ,
372
378
name : 'deep-deep-deep' ,
373
379
encapsulate : true
374
380
} ) )
375
381
376
382
fastify . register ( fp ( getFn ( 'deep-deep -> not-encapsulated-2' ) , {
377
- fastify : '4 .x' ,
383
+ fastify : '5 .x' ,
378
384
name : 'not-encapsulated-2'
379
385
} ) )
380
386
381
387
next ( )
382
388
} , {
383
- fastify : '4 .x' ,
389
+ fastify : '5 .x' ,
384
390
name : 'deep-deep' ,
385
391
encapsulate : true
386
392
} ) )
387
393
388
394
fastify . register ( fp ( getFn ( 'plugin -> not-encapsulated' ) , {
389
- fastify : '4 .x' ,
395
+ fastify : '5 .x' ,
390
396
name : 'not-encapsulated'
391
397
} ) )
392
398
0 commit comments