feat: add reusable jobqueue library
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
25
tests/SseSerializer.test.ts
Normal file
25
tests/SseSerializer.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { SseSerializer } from '../src/index.js';
|
||||
|
||||
describe('SseSerializer', () => {
|
||||
it('formats SSE events', () => {
|
||||
const serializer = new SseSerializer();
|
||||
const event = serializer.event('job:completed', {
|
||||
type: 'job:completed',
|
||||
jobId: 'job-1',
|
||||
timestamp: '2026-01-01T00:00:00.000Z',
|
||||
});
|
||||
|
||||
expect(event).toContain('event: job:completed');
|
||||
expect(event).toContain('"jobId":"job-1"');
|
||||
expect(event.endsWith('\n\n')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns SSE headers', () => {
|
||||
expect(SseSerializer.headers()).toEqual({
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Cache-Control': 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
'X-Accel-Buffering': 'no',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user