-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add example fixture with
@nuxt/content
(#631)
- Loading branch information
Showing
8 changed files
with
1,665 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div>Index page</div> | ||
<div>title: {{ posts[0].title }}</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
definePageMeta({ | ||
value: 'set in index' | ||
}) | ||
const posts = await queryContent('/').limit(1).find() | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Nuxt Content | ||
|
||
This page corresponds to the `/` route of your website. You can delete it or create another file in the `content/` directory. | ||
|
||
Try to navigate to [/about](/about). These 2 pages are rendered by the `pages/[...slug].vue` component. | ||
|
||
--- | ||
|
||
Look at the [Content documentation](https://content.nuxtjs.org/) to learn more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
modules: ['@nuxt/content'] | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "nuxt build", | ||
"dev": "nuxt dev", | ||
"dev:prepare": "nuxt prepare", | ||
"generate": "nuxt generate", | ||
"test": "vitest", | ||
"preview": "nuxt preview" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/content": "^2.9.0", | ||
"@nuxt/test-utils": "latest", | ||
"nuxt": "^3.8.2", | ||
"vitest": "1.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { mockNuxtImport, mountSuspended } from '@nuxt/test-utils/runtime' | ||
|
||
import App from '~/app.vue' | ||
|
||
// Example usage: queryContent('/').limit(1).find() | ||
mockNuxtImport('queryContent', () => (_id: string) => ({ | ||
limit: (_limit: number) => ({ | ||
find: () => [{ | ||
title: 'My page' | ||
}] | ||
}) | ||
})) | ||
|
||
describe('test utils', () => { | ||
it('can mount components within nuxt suspense', async () => { | ||
const component = await mountSuspended(App) | ||
expect(component.html()).toMatchInlineSnapshot(` | ||
"<div>Index page</div> | ||
<div>title: My page</div>" | ||
`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
// https://v3.nuxtjs.org/concepts/typescript | ||
"extends": "./.nuxt/tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineVitestConfig } from '@nuxt/test-utils/config' | ||
|
||
export default defineVitestConfig({ | ||
test: { | ||
environment: 'nuxt' | ||
}, | ||
}) |
Oops, something went wrong.