mirror of
https://github.com/wahyd4/heygo.git
synced 2026-08-08 21:05:48 +10:00
feat: scaffold cloudflare shortlinks app
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import worker from '../worker/index';
|
||||
|
||||
function fetchWorker(path: string) {
|
||||
const request = new Request(`https://heygo.test${path}`);
|
||||
|
||||
return worker.fetch(request as unknown as Parameters<typeof worker.fetch>[0]);
|
||||
}
|
||||
|
||||
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' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user