@@ -548,8 +548,59 @@ test('/documentation should display index html with correct asset urls', async (
548
548
url : '/documentation'
549
549
} )
550
550
551
- t . equal ( res . payload . includes ( 'href="/documentation/static/index.css"' ) , true )
552
- t . equal ( res . payload . includes ( 'src="/documentation/static/theme/theme-js.js"' ) , true )
553
- t . equal ( res . payload . includes ( 'href="/documentation/index.css"' ) , false )
554
- t . equal ( res . payload . includes ( 'src="/documentation/theme/theme-js.js"' ) , false )
551
+ t . equal ( res . payload . includes ( 'href="./documentation/static/index.css"' ) , true )
552
+ t . equal ( res . payload . includes ( 'src="./documentation/static/theme/theme-js.js"' ) , true )
553
+ t . equal ( res . payload . includes ( 'href="./documentation/index.css"' ) , false )
554
+ t . equal ( res . payload . includes ( 'src="./documentation/theme/theme-js.js"' ) , false )
555
+ } )
556
+
557
+ test ( '/documentation/ should display index html with correct asset urls' , async ( t ) => {
558
+ t . plan ( 4 )
559
+ const fastify = Fastify ( )
560
+ await fastify . register ( fastifySwagger , swaggerOption )
561
+ await fastify . register ( fastifySwaggerUi , { theme : { js : [ { filename : 'theme-js.js' } ] } } )
562
+
563
+ const res = await fastify . inject ( {
564
+ method : 'GET' ,
565
+ url : '/documentation/'
566
+ } )
567
+
568
+ t . equal ( res . payload . includes ( 'href="./static/index.css"' ) , true )
569
+ t . equal ( res . payload . includes ( 'src="./static/theme/theme-js.js"' ) , true )
570
+ t . equal ( res . payload . includes ( 'href="./index.css"' ) , false )
571
+ t . equal ( res . payload . includes ( 'src="./theme/theme-js.js"' ) , false )
572
+ } )
573
+
574
+ test ( '/docs should display index html with correct asset urls when documentation prefix is set' , async ( t ) => {
575
+ t . plan ( 4 )
576
+ const fastify = Fastify ( )
577
+ await fastify . register ( fastifySwagger , swaggerOption )
578
+ await fastify . register ( fastifySwaggerUi , { theme : { js : [ { filename : 'theme-js.js' } ] } , routePrefix : '/docs' } )
579
+
580
+ const res = await fastify . inject ( {
581
+ method : 'GET' ,
582
+ url : '/docs'
583
+ } )
584
+
585
+ t . equal ( res . payload . includes ( 'href="./docs/static/index.css"' ) , true )
586
+ t . equal ( res . payload . includes ( 'src="./docs/static/theme/theme-js.js"' ) , true )
587
+ t . equal ( res . payload . includes ( 'href="./docs/index.css"' ) , false )
588
+ t . equal ( res . payload . includes ( 'src="./docs/theme/theme-js.js"' ) , false )
589
+ } )
590
+
591
+ test ( '/docs/ should display index html with correct asset urls when documentation prefix is set' , async ( t ) => {
592
+ t . plan ( 4 )
593
+ const fastify = Fastify ( )
594
+ await fastify . register ( fastifySwagger , swaggerOption )
595
+ await fastify . register ( fastifySwaggerUi , { theme : { js : [ { filename : 'theme-js.js' } ] } , routePrefix : '/docs' } )
596
+
597
+ const res = await fastify . inject ( {
598
+ method : 'GET' ,
599
+ url : '/docs/'
600
+ } )
601
+
602
+ t . equal ( res . payload . includes ( 'href="./static/index.css"' ) , true )
603
+ t . equal ( res . payload . includes ( 'src="./static/theme/theme-js.js"' ) , true )
604
+ t . equal ( res . payload . includes ( 'href="./index.css"' ) , false )
605
+ t . equal ( res . payload . includes ( 'src="./theme/theme-js.js"' ) , false )
555
606
} )
0 commit comments