Skip to content

Commit 6ddbcc4

Browse files
authored
Merge branch 'master' into migrate-tap-to-native-test-runner
Signed-off-by: Aras Abbasi <aras.abbasi@googlemail.com>
2 parents af8c20a + a625094 commit 6ddbcc4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Diff for: test/route.test.js

+51
Original file line numberDiff line numberDiff line change
@@ -605,3 +605,54 @@ test('/docs/ should display index html with correct asset urls when documentatio
605605
t.assert.strictEqual(res.payload.includes('href="./index.css"'), false)
606606
t.assert.strictEqual(res.payload.includes('src="./theme/theme-js.js"'), false)
607607
})
608+
609+
test('/documentation/ should display index html with correct asset urls', async (t) => {
610+
t.plan(4)
611+
const fastify = Fastify()
612+
await fastify.register(fastifySwagger, swaggerOption)
613+
await fastify.register(fastifySwaggerUi, { theme: { js: [{ filename: 'theme-js.js' }] } })
614+
615+
const res = await fastify.inject({
616+
method: 'GET',
617+
url: '/documentation/'
618+
})
619+
620+
t.equal(res.payload.includes('href="./static/index.css"'), true)
621+
t.equal(res.payload.includes('src="./static/theme/theme-js.js"'), true)
622+
t.equal(res.payload.includes('href="./index.css"'), false)
623+
t.equal(res.payload.includes('src="./theme/theme-js.js"'), false)
624+
})
625+
626+
test('/docs should display index html with correct asset urls when documentation prefix is set', async (t) => {
627+
t.plan(4)
628+
const fastify = Fastify()
629+
await fastify.register(fastifySwagger, swaggerOption)
630+
await fastify.register(fastifySwaggerUi, { theme: { js: [{ filename: 'theme-js.js' }] }, routePrefix: '/docs' })
631+
632+
const res = await fastify.inject({
633+
method: 'GET',
634+
url: '/docs'
635+
})
636+
637+
t.equal(res.payload.includes('href="/docs/static/index.css"'), true)
638+
t.equal(res.payload.includes('src="/docs/static/theme/theme-js.js"'), true)
639+
t.equal(res.payload.includes('href="/docs/index.css"'), false)
640+
t.equal(res.payload.includes('src="/docs/theme/theme-js.js"'), false)
641+
})
642+
643+
test('/docs/ should display index html with correct asset urls when documentation prefix is set', async (t) => {
644+
t.plan(4)
645+
const fastify = Fastify()
646+
await fastify.register(fastifySwagger, swaggerOption)
647+
await fastify.register(fastifySwaggerUi, { theme: { js: [{ filename: 'theme-js.js' }] }, routePrefix: '/docs' })
648+
649+
const res = await fastify.inject({
650+
method: 'GET',
651+
url: '/docs/'
652+
})
653+
654+
t.equal(res.payload.includes('href="./static/index.css"'), true)
655+
t.equal(res.payload.includes('src="./static/theme/theme-js.js"'), true)
656+
t.equal(res.payload.includes('href="./index.css"'), false)
657+
t.equal(res.payload.includes('src="./theme/theme-js.js"'), false)
658+
})

0 commit comments

Comments
 (0)