From 91d6adf8e07f4076d0d2f307dbaf4e8642114f53 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Mon, 22 Jul 2024 14:15:09 +0200 Subject: [PATCH] useFakeTimers for initRundown in tests (#1150) --- apps/server/src/stores/__tests__/runtimeState.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/server/src/stores/__tests__/runtimeState.test.ts b/apps/server/src/stores/__tests__/runtimeState.test.ts index 6b372dfb30..d5b76d5b3a 100644 --- a/apps/server/src/stores/__tests__/runtimeState.test.ts +++ b/apps/server/src/stores/__tests__/runtimeState.test.ts @@ -83,7 +83,7 @@ describe('mutation on runtimeState', () => { vi.clearAllMocks(); }); - describe('playback operations', () => { + describe('playback operations', async () => { it('refuses if nothing is loaded', () => { let success = start(mockState); expect(success).toBe(false); @@ -159,8 +159,12 @@ describe('mutation on runtimeState', () => { const event1 = { ...mockEvent, id: 'event1', timeStart: 0, timeEnd: 1000, duration: 1000 }; const event2 = { ...mockEvent, id: 'event2', timeStart: 1000, timeEnd: 1500, duration: 500 }; // force update - initRundown([event1, event2], {}); - test('runtime offset', () => { + vi.useFakeTimers(); + await initRundown([event1, event2], {}); + vi.runAllTimers(); + vi.useRealTimers(); + + test('runtime offset', async () => { // 1. Load event load(event1, [event1, event2]); let newState = getState();