返回 DeepSeek-Reasonix
goal-runtime.test.ts
根目录 / desktop / frontend / src / __tests__ / goal-runtime.test.ts
1 import { formatGoalWorkTime } from "../lib/goalRuntime";
2
3 function equal(actual: unknown, expected: unknown, label: string) {
4 if (actual !== expected) throw new Error(`${label}: expected ${String(expected)}, got ${String(actual)}`);
5 }
6
7 equal(formatGoalWorkTime(undefined), "0s", "old payload without workDurationMs");
8 equal(formatGoalWorkTime(0), "0s", "zero duration");
9 equal(formatGoalWorkTime(42 * 60_000), "42m", "minute duration");
10 equal(formatGoalWorkTime((2 * 60 + 7) * 60_000), "2h 7m", "hour duration");
11
12 console.log("goal runtime formatting: passed");
13
13 lines TYPESCRIPT