Initial commit

This commit is contained in:
AI
2026-05-03 07:26:12 +00:00
commit 776d374b59
57 changed files with 15968 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
async function loadPlugin() {
vi.resetModules()
vi.stubGlobal('defineNuxtPlugin', (setup: unknown) => setup)
return (await import('../app/plugins/api.client')).default
}
describe('api plugin', () => {
beforeEach(() => {
vi.restoreAllMocks()
vi.unstubAllGlobals()
})
it('creates API clients from runtime config values', async () => {
vi.stubGlobal('useRuntimeConfig', () => ({
public: {
apiBaseUrl: 'https://api.example.test',
apiTimeoutMs: 4321
}
}))
const plugin = await loadPlugin()
const { provide } = plugin()
const fetchMock = vi.fn().mockResolvedValue({ status: 'ok' })
vi.stubGlobal('$fetch', fetchMock)
const response = await provide.api.example.getHealth()
expect(response).toEqual({ status: 'ok' })
expect(fetchMock).toHaveBeenCalledWith('/health', {
baseURL: 'https://api.example.test',
signal: undefined,
timeout: 4321
})
})
})