AI Implementation feature(820): Project Scaffold and Platform Foundations (#1)
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { EventStatusService } from '../../backend/src/common/services/event-status.service';
|
||||
|
||||
describe('EventStatusService', () => {
|
||||
const settings = {
|
||||
get: jest.fn(),
|
||||
} as any;
|
||||
|
||||
beforeEach(() => {
|
||||
settings.get.mockReset();
|
||||
});
|
||||
|
||||
it('returns Stopped before start with positive countdown', async () => {
|
||||
const start = new Date(Date.now() + 60_000).toISOString();
|
||||
const end = new Date(Date.now() + 120_000).toISOString();
|
||||
settings.get.mockImplementation(async (k: string) => (k === 'eventStartUtc' ? start : end));
|
||||
const svc = new EventStatusService(settings);
|
||||
const s = await svc.getStatus();
|
||||
expect(s.status).toBe('Stopped');
|
||||
expect(s.countdownMs).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('returns Running between start and end', async () => {
|
||||
const start = new Date(Date.now() - 30_000).toISOString();
|
||||
const end = new Date(Date.now() + 60_000).toISOString();
|
||||
settings.get.mockImplementation(async (k: string) => (k === 'eventStartUtc' ? start : end));
|
||||
const svc = new EventStatusService(settings);
|
||||
const s = await svc.getStatus();
|
||||
expect(s.status).toBe('Running');
|
||||
expect(s.countdownMs).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('returns Stopped after end with zero countdown', async () => {
|
||||
const start = new Date(Date.now() - 120_000).toISOString();
|
||||
const end = new Date(Date.now() - 60_000).toISOString();
|
||||
settings.get.mockImplementation(async (k: string) => (k === 'eventStartUtc' ? start : end));
|
||||
const svc = new EventStatusService(settings);
|
||||
const s = await svc.getStatus();
|
||||
expect(s.status).toBe('Stopped');
|
||||
expect(s.countdownMs).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user