35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
|
|
import { formatChineseDate, formatDate, formatDateTime } from "./formatters.js";
|
|
|
|
describe("formatDate", () => {
|
|
it("formats Date values without browser-native English text", () => {
|
|
assert.equal(formatDate(new Date(2026, 5, 13, 9, 30)), "2026-06-13");
|
|
});
|
|
});
|
|
|
|
describe("formatDateTime", () => {
|
|
it("formats Date values as numeric date-time text", () => {
|
|
assert.equal(formatDateTime(new Date(2026, 5, 13, 9, 30)), "2026-06-13 09:30");
|
|
});
|
|
|
|
it("keeps date-only strings as date text instead of adding synthetic time", () => {
|
|
assert.equal(formatDateTime("2026-06-13"), "2026-06-13");
|
|
});
|
|
});
|
|
|
|
describe("formatChineseDate", () => {
|
|
it("formats Date values as Chinese year-month-day text", () => {
|
|
assert.equal(formatChineseDate(new Date(2026, 5, 13, 9, 30)), "2026年06月13日");
|
|
});
|
|
|
|
it("formats ISO date strings as Chinese year-month-day text", () => {
|
|
assert.equal(formatChineseDate("2026-06-13T15:45:00"), "2026年06月13日");
|
|
});
|
|
|
|
it("keeps empty values aligned with other display formatters", () => {
|
|
assert.equal(formatChineseDate(""), "-");
|
|
});
|
|
});
|