Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ done

if [[ $ARG1 ]]
then
echo "npx vitest run -t $ARG1"
(npx vitest run -t $ARG1.test)
echo "npx vitest run $ARG1"
(npx vitest run $ARG1.test)
else
echo "npx vitest run"
(npx vitest run)
Expand Down
9 changes: 9 additions & 0 deletions src/runtime/pages/document-driven.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
<script setup lang="ts">
import { createError } from 'h3'
import { useContent, useContentHead } from '#imports'

const { page } = useContent()

// Page not found
if (!page.value) {
throw createError({
statusCode: 404,
statusMessage: `Page not found: ${useRoute().path}`
})
}

useContentHead(page)
</script>

Expand Down
11 changes: 10 additions & 1 deletion test/document-driven.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('fixtures:document-driven', async () => {
test('<title> from front-matter', async () => {
const html = await $fetch('/')

expect(html).contains('Home | Document Driven Fixture')
expect(html).contains('<title>Home</title>')
})

test('disabled document driven', async () => {
Expand Down Expand Up @@ -46,4 +46,13 @@ describe('fixtures:document-driven', async () => {
expect(html).contains('with previous link /layout')
expect(html).contains('with next link /no-surround')
})

test('404 page', async () => {
try {
await $fetch('/page-not-found')
} catch (e) {
expect(e.response.status).toBe(404)
expect(e.response.statusText).toBe('Page not found: /page-not-found')
}
})
})
82 changes: 0 additions & 82 deletions test/fixtures/document-driven/pages/[...slug].vue

This file was deleted.