import { describe, expect, it } from 'vitest'; import worker from '../worker/index'; class FakeExecutionContext { waitUntil(): void {} passThroughOnException(): void {} } function fetchWorker(path: string) { const request = new Request(`https://heygo.test${path}`); const env = { DB: {} as D1Database, PUBLIC_HOST: 'heygo.cc', PRIVATE_HOST: 'my.heygo.cc', APP_BASE_URL: 'https://heygo.cc', COOKIE_DOMAIN: '.heygo.cc', }; const ctx = new FakeExecutionContext(); return worker.fetch( request as unknown as Parameters[0], env as unknown as Parameters[1], ctx as unknown as Parameters[2], ); } describe('worker API scaffold', () => { it('responds to the health endpoint', async () => { const response = await fetchWorker('/api/health'); expect(response.status).toBe(200); expect(response.headers.get('content-type')).toContain('application/json'); await expect(response.json()).resolves.toEqual({ ok: true, service: 'heygo-worker', }); }); it('returns 404 JSON for unknown API routes', async () => { const response = await fetchWorker('/api/missing'); expect(response.status).toBe(404); await expect(response.json()).resolves.toEqual({ error: 'Not found' }); }); });