Files
slaguru666andClaude Opus 4.8 73a7ea72ad feat: break timer — pause the session clock so breaks don't poison drift
Add <break-timer> tray: pick a duration, Start break pauses the session
clock (reusing clock.pause/resume), End break resumes it — so meal/comfort
break time is excluded from elapsed and drift stays honest. The shell owns
pause/resume + persistence (break store key); the rail shows a on-break
badge and gains a coffee chip. fmtCountdown (M:SS) added to format.js.

tests/components/break-timer.test.js + gm-shell-break.test.js (incl. the
30-play/20-break/10-play drift-honesty case) + fmtCountdown. 159 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 23:00:17 +01:00

23 lines
833 B
JavaScript

import { describe, it, expect } from 'vitest';
import { fmtElapsed, fmtDrift, fmtCountdown } from '../../src/core/format.js';
describe('formatting', () => {
it('formats elapsed time', () => {
expect(fmtElapsed(0)).toBe('0:00');
expect(fmtElapsed(65 * 1000)).toBe('0:01');
expect(fmtElapsed(112 * 60 * 1000)).toBe('1:52');
});
it('formats drift with direction', () => {
expect(fmtDrift(null)).toBe('');
expect(fmtDrift(0)).toBe('on time');
expect(fmtDrift(6)).toBe('+6 behind');
expect(fmtDrift(-3)).toBe('3 ahead');
});
it('formats a countdown as M:SS', () => {
expect(fmtCountdown(0)).toBe('0:00');
expect(fmtCountdown(9 * 60000 + 47 * 1000)).toBe('9:47');
expect(fmtCountdown(10 * 60000)).toBe('10:00');
expect(fmtCountdown(-5000)).toBe('0:00'); // clamps negatives
});
});