19 lines
755 B
TypeScript
19 lines
755 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { formatTerminalLogTime, formatTerminalServerTime } from "./logTime";
|
|
|
|
describe("formatTerminalLogTime", () => {
|
|
it("uses only the server event timestamp", () => {
|
|
expect(formatTerminalLogTime("2026-08-24T01:23:44Z")).toMatch(/^\d{2}:\d{2}:\d{2}(?:\s*[AP]M)?$/);
|
|
});
|
|
|
|
it("falls back to the event timestamp for generic logs", () => {
|
|
expect(formatTerminalLogTime("not-a-timestamp")).toBe("时间未知");
|
|
});
|
|
|
|
it("does not use the browser clock before the server clock is synchronized", () => {
|
|
expect(formatTerminalServerTime()).toBe("时间同步中");
|
|
expect(formatTerminalServerTime("2026-08-14T00:00:00Z")).toBe(formatTerminalLogTime("2026-08-14T00:00:00Z"));
|
|
});
|
|
});
|