feat(worker): server-authoritative Stopwatch screen with active-session recovery

This commit is contained in:
Bas van Rossem
2026-06-17 16:24:56 +02:00
parent 1ecad6bbb4
commit 5af5a9c2bb
5 changed files with 625 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest';
import { elapsedSeconds, formatTime } from './stopwatch';
describe('stopwatch logic', () => {
it('formats seconds as HH:MM:SS', () => {
expect(formatTime(0)).toBe('00:00:00');
expect(formatTime(65)).toBe('00:01:05');
expect(formatTime(3661)).toBe('01:01:01');
});
it('computes elapsed seconds since start excluding paused time', () => {
expect(elapsedSeconds(1000, 6000, 0)).toBe(5);
expect(elapsedSeconds(1000, 6000, 2000)).toBe(3);
});
it('never returns a negative elapsed value', () => {
expect(elapsedSeconds(5000, 1000, 0)).toBe(0);
});
});