fix(auto-reply): guard date stamp formatting · openclaw/openclaw@fb61363
steipete
·
2026-05-30
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import { describe, expect, it } from "vitest"; |
2 | | -import { normalizeTimestamp } from "./date-time.js"; |
| 1 | +import { afterEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { formatDateStamp, normalizeTimestamp } from "./date-time.js"; |
3 | 3 | |
4 | 4 | describe("normalizeTimestamp", () => { |
5 | 5 | it("normalizes numeric second and millisecond timestamps", () => { |
@@ -18,3 +18,15 @@ describe("normalizeTimestamp", () => {
|
18 | 18 | expect(normalizeTimestamp("999999999999999999999999")).toBeUndefined(); |
19 | 19 | }); |
20 | 20 | }); |
| 21 | + |
| 22 | +describe("formatDateStamp", () => { |
| 23 | +afterEach(() => { |
| 24 | +vi.restoreAllMocks(); |
| 25 | +}); |
| 26 | + |
| 27 | +it("falls back when nowMs is outside Date range", () => { |
| 28 | +vi.spyOn(Date, "now").mockReturnValue(Date.UTC(2026, 4, 30, 12, 0, 0)); |
| 29 | + |
| 30 | +expect(formatDateStamp(8_640_000_000_000_001, "UTC")).toBe("2026-05-30"); |
| 31 | +}); |
| 32 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。