Scaffolding baseline

This commit is contained in:
2026-07-16 20:47:33 +02:00
parent e9cbc56903
commit 38b4e8fd43
32 changed files with 3114 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { fetchHealth, getApiBaseUrl } from './client'
describe('getApiBaseUrl', () => {
it('defaults to localhost:8080 when unset', () => {
expect(getApiBaseUrl()).toBe('http://localhost:8080')
})
})
describe('fetchHealth', () => {
afterEach(() => {
vi.restoreAllMocks()
})
it('returns parsed health payload', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ status: 'ok' }),
})
const health = await fetchHealth(fetchMock)
expect(fetchMock).toHaveBeenCalledWith('http://localhost:8080/health')
expect(health).toEqual({ status: 'ok' })
})
it('throws when the response is not ok', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: false,
status: 503,
json: async () => ({}),
})
await expect(fetchHealth(fetchMock)).rejects.toThrow(
'health check failed: 503',
)
})
})