assert non null and update test (#1604)

This commit is contained in:
Alex Christoffer Rasmussen
2025-05-11 18:29:18 +02:00
committed by arc-alex
parent c9bf6d9812
commit 66cd1decde
2 changed files with 11 additions and 8 deletions
@@ -737,6 +737,7 @@ describe('getRuntimeOffset()', () => {
},
runtime: {
actualStart: 150,
plannedStart: 100,
},
} as RuntimeState;
@@ -760,6 +761,7 @@ describe('getRuntimeOffset()', () => {
},
runtime: {
actualStart: 150,
plannedStart: 100,
},
} as RuntimeState;
@@ -784,6 +786,7 @@ describe('getRuntimeOffset()', () => {
},
runtime: {
actualStart: 100,
plannedStart: 100,
},
} as RuntimeState;
@@ -809,6 +812,7 @@ describe('getRuntimeOffset()', () => {
},
runtime: {
actualStart: 100,
plannedStart: 100,
},
} as RuntimeState;
+7 -8
View File
@@ -122,19 +122,18 @@ export function getRuntimeOffset(state: RuntimeState): { absoluteOffset: number;
return { absoluteOffset: 0, relativeOffset: 0 };
}
// eslint-disable-next-line no-unused-labels -- dev code path
DEV: {
// we know current exists as long as eventNow exists
if (state.timer.current === null) {
throw new Error('timerUtils.calculate: current must be set');
}
}
const { clock } = state;
const { countToEnd, timeStart } = state.eventNow;
const { addedTime, current, startedAt } = state.timer;
const { actualStart, plannedStart } = state.runtime;
// eslint-disable-next-line no-unused-labels -- dev code path
DEV: {
// we know current exists as long as eventNow exists
if (current === null) throw new Error('timerUtils.getRuntimeOffset: state.timer.current must be set');
if (plannedStart === null) throw new Error('timerUtils.getRuntimeOffset: state.runtime.plannedStart must be set');
}
// if we havent started, but the timer is armed
// the offset is the difference to the schedule
if (startedAt === null) {