This commit is contained in:
41
packages/server/tests/local/notifications.test.ts
Normal file
41
packages/server/tests/local/notifications.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('Notification SSE Route', () => {
|
||||
it('exports notificationRoutes function', async () => {
|
||||
const mod = await import('../../src/local/routes/notifications.js');
|
||||
expect(mod.notificationRoutes).toBeDefined();
|
||||
expect(typeof mod.notificationRoutes).toBe('function');
|
||||
});
|
||||
|
||||
it('exports emitNotification function', async () => {
|
||||
const mod = await import('../../src/local/routes/notifications.js');
|
||||
expect(mod.emitNotification).toBeDefined();
|
||||
expect(typeof mod.emitNotification).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('NotificationEvent shape', () => {
|
||||
it('has required fields', () => {
|
||||
const event = {
|
||||
type: 'notification' as const,
|
||||
title: 'Test',
|
||||
body: 'Test body',
|
||||
category: 'cron' as const,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
expect(event.type).toBe('notification');
|
||||
expect(event.category).toBe('cron');
|
||||
});
|
||||
|
||||
it('supports optional actionUrl', () => {
|
||||
const event = {
|
||||
type: 'notification' as const,
|
||||
title: 'Task',
|
||||
body: 'Review Q1',
|
||||
category: 'task' as const,
|
||||
timestamp: new Date().toISOString(),
|
||||
actionUrl: '/tasks',
|
||||
};
|
||||
expect(event.actionUrl).toBe('/tasks');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user