Files
timelog/tests/record.test.ts
T
minhtrannhatandClaude Opus 5.5 a6ca255835 Add Timelog: show the timer in the tab title and simplify the code
This is the first commit of the project, at the state that runs on
timelog.minhtrannhat.com.

Changes in this state:
- Remove redundant UI text from the sidebar, timer and insights pages.
- Show the remaining time and tag in the browser tab title while a
  session runs.
- Put the shared record type and the due and end helpers in
  src/shared/record.ts.
- Remove the startup tag migration and the one-time Forest import
  script. The live data does not need them.
- Remove unused CSS, Playwright ignore rules and duplicate helpers.
- Do not track Forest CSV exports, because they contain private data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:42:58 -05:00

18 lines
697 B
TypeScript

import { expect, test } from "bun:test";
import { dueMs, recordEnd, type TimeRecord } from "../src/shared/record.ts";
const base: TimeRecord = {
id: "session_record_test", startMs: 1_000_000, endMs: null, targetSeconds: 60, tag: "Study", note: "",
treeType: "", isSuccess: null, source: "timer", rawStart: null, rawEnd: null, deleted: false,
};
test("a running session ends now until it is due", () => {
expect(dueMs(base)).toBe(1_060_000);
expect(recordEnd(base, 1_030_000)).toBe(1_030_000);
expect(recordEnd(base, 2_000_000)).toBe(1_060_000);
});
test("a finished record keeps its own end", () => {
expect(recordEnd({ ...base, endMs: 1_010_000 }, 2_000_000)).toBe(1_010_000);
});