refactor(timer): elapsed is active time from start

This commit is contained in:
Carlos Valente
2026-06-28 19:12:22 +02:00
committed by Carlos Valente
parent 4f4626a163
commit 161ab3fe13
12 changed files with 196 additions and 6 deletions
@@ -47,6 +47,23 @@ describe('isRestorePoint()', () => {
expect(isRestorePoint(restorePoint)).toBe(true);
});
it('accepts optional paused duration', () => {
const restorePoint: RestorePoint = {
playback: Playback.Roll,
selectedEventId: '123',
startedAt: 1,
addedTime: 2,
pausedAt: null,
pausedDuration: 3000,
firstStart: 1,
startEpoch: asInstant(1),
currentDay: 0,
};
expect(isRestorePoint(restorePoint)).toBe(true);
expect(isRestorePoint({ ...restorePoint, pausedDuration: '3000' })).toBe(false);
});
describe('rejects a badly formatted file', () => {
it('with invalid playback value', () => {
const restorePoint = {
@@ -46,6 +46,10 @@ export function isRestorePoint(restorePoint: unknown): restorePoint is RestorePo
return false;
}
if ('pausedDuration' in restorePoint && !is.number(restorePoint.pausedDuration)) {
return false;
}
if (!is.number(restorePoint.firstStart) && restorePoint.firstStart !== null) {
return false;
}
@@ -6,6 +6,7 @@ export type RestorePoint = {
startedAt: MaybeNumber;
addedTime: number;
pausedAt: MaybeNumber;
pausedDuration?: number;
firstStart: MaybeNumber;
startEpoch: Maybe<Instant>;
currentDay: MaybeNumber;