All checks were successful
Deploy eCourt Note Web to Server / Validate Database Schema (Drizzle) (push) Successful in 3s
Deploy eCourt Note Web to Server / Build Web Docker Image (push) Successful in 43s
Deploy eCourt Note Web to Server / Deploy eCourt Note Web to Server (push) Successful in 3s
Deploy eCourt Note Web to Server / Notify Deployment Status (push) Successful in 1s
Co-Authored-By: Claude Code <noreply@anthropic.com>
26 lines
1.7 KiB
TypeScript
26 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatThaiDate } from "@/utils/date-format";
|
|
|
|
// สร้าง Date จาก local components แล้ววนผ่าน ISO กลับ — ผล test ไม่ขึ้นกับ
|
|
// timezone ของเครื่องที่รัน (เว้นช่วง DST transition ทับพอดี ซึ่งไทยไม่มี)
|
|
describe("formatThaiDate — วันที่ไทยแบบเต็ม พ.ศ. ตามธรรมเนียมเอกสารราชการ", () => {
|
|
it("ไม่มีเวลา → 18 กันยายน พ.ศ. 2569", () => {
|
|
const d = new Date(2026, 8, 18, 16, 33, 0);
|
|
expect(formatThaiDate(d.toISOString())).toBe("18 กันยายน พ.ศ. 2569");
|
|
});
|
|
|
|
it("มีเวลา → 18 กันยายน พ.ศ. 2569 16:33:00 น.", () => {
|
|
const d = new Date(2026, 8, 18, 16, 33, 0);
|
|
expect(formatThaiDate(d.toISOString(), true)).toBe("18 กันยายน พ.ศ. 2569 16:33:00 น.");
|
|
});
|
|
|
|
it("วัน/ชั่วโมง/นาที/วินาทีหลักเดียวไม่มีศูนย์นำหน้าที่วัน + ศูนย์นำหน้าที่เวลา", () => {
|
|
const d = new Date(2026, 10, 5, 9, 5, 3);
|
|
expect(formatThaiDate(d.toISOString(), true)).toBe("5 พฤศจิกายน พ.ศ. 2569 09:05:03 น.");
|
|
});
|
|
|
|
it("29 กุมภาพันธ์ปีอธิกสุรทิน (2028 → พ.ศ. 2571)", () => {
|
|
const d = new Date(2028, 1, 29, 23, 59, 59);
|
|
expect(formatThaiDate(d.toISOString(), true)).toBe("29 กุมภาพันธ์ พ.ศ. 2571 23:59:59 น.");
|
|
});
|
|
});
|