Skip to content

Commit b82e60f

Browse files
authored
test: add basic tests for ai
1 parent 2a03a99 commit b82e60f

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

test/ai.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { fileURLToPath } from 'node:url'
2+
import { describe, it, expect } from 'vitest'
3+
import { setup, $fetch } from '@nuxt/test-utils'
4+
5+
describe('Ai', async () => {
6+
await setup({
7+
rootDir: fileURLToPath(new URL('./fixtures/ai', import.meta.url)),
8+
dev: true
9+
})
10+
11+
it('Check manifest (Analytics is enabled)', async () => {
12+
const manifest = await $fetch('/api/_hub/manifest')
13+
expect(manifest).toMatchObject({
14+
storage: {
15+
database: false,
16+
kv: false,
17+
blob: false
18+
},
19+
features: {
20+
ai: true,
21+
analytics: false,
22+
cache: false
23+
}
24+
})
25+
})
26+
})

test/fixtures/ai/app.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script setup lang="ts">
2+
import { useFetch } from '#app'
3+
4+
const { data: manifest } = useFetch<Record<string, any>>('/api/_hub/manifest')
5+
</script>
6+
7+
<template>
8+
<h3>Data storage enabled:</h3>
9+
<ul>
10+
<li
11+
v-for="primitive in Object.keys(manifest?.storage || {})"
12+
:key="primitive"
13+
>
14+
{{ primitive }}
15+
</li>
16+
</ul>
17+
</template>

test/fixtures/ai/nuxt.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineNuxtConfig } from 'nuxt/config'
2+
3+
export default defineNuxtConfig({
4+
modules: [
5+
'../../../src/module'
6+
],
7+
hub: {
8+
ai: true
9+
}
10+
})

test/fixtures/ai/package.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"private": true,
3+
"name": "hub-ai-test",
4+
"type": "module"
5+
}

0 commit comments

Comments
 (0)