refactor: 统一管理页面布局 — FilterToolbar + usePageSearchParams + parseListParams
This commit is contained in:
25
tests/web/format.test.ts
Normal file
25
tests/web/format.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from "bun:test";
|
||||
|
||||
import { formatDatetime } from "../../src/web/shared/utils/format";
|
||||
|
||||
describe("formatDatetime", () => {
|
||||
it("formats ISO date string to YYYY-MM-DD HH:mm:ss", () => {
|
||||
expect(formatDatetime("2024-06-15T14:30:45.123Z")).toMatch(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/);
|
||||
});
|
||||
|
||||
it("pads single-digit month, day, hour, minute, second", () => {
|
||||
const result = formatDatetime("2024-01-05T09:08:07.000Z");
|
||||
expect(result).toMatch(/2024-0[1-9]-0[1-9] 0[0-9]:0[0-9]:0[0-9]/);
|
||||
});
|
||||
|
||||
it("handles end-of-year date", () => {
|
||||
const result = formatDatetime("2024-12-31T23:59:59.000Z");
|
||||
expect(result).toContain("2024");
|
||||
expect(result).toContain("59:59");
|
||||
});
|
||||
|
||||
it("produces consistent output format", () => {
|
||||
const result = formatDatetime("2024-06-15T14:30:45.123Z");
|
||||
expect(result.length).toBe(19);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user