feat(worker): server-authoritative Stopwatch screen with active-session recovery
This commit is contained in:
19
apps/worker/src/lib/stopwatch.test.ts
Normal file
19
apps/worker/src/lib/stopwatch.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user