4dbd2eb441
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
import { formatDate, formatDateTime, formatMoney } from "./format";
|
||
|
||
// Intl çıktısındaki boşluklar (ör. U+00A0) ortama göre değişebilir; karşılaştırmada normalleştir.
|
||
const norm = (s: string) => s.replace(/\s/g, " ");
|
||
|
||
describe("formatMoney", () => {
|
||
it("kuruşu TL olarak Türkçe biçimde gösterir", () => {
|
||
expect(norm(formatMoney(125050))).toBe("₺1.250,50");
|
||
expect(norm(formatMoney(0))).toBe("₺0,00");
|
||
expect(norm(formatMoney(-9999))).toBe("-₺99,99");
|
||
});
|
||
|
||
it("tamsayı olmayan tutarı reddeder", () => {
|
||
expect(() => formatMoney(12.5)).toThrow(TypeError);
|
||
});
|
||
});
|
||
|
||
describe("formatDate", () => {
|
||
it("İstanbul saatine göre gün sınırını uygular", () => {
|
||
// 31.12.2026 21:30 UTC = 01.01.2027 00:30 İstanbul (UTC+3)
|
||
expect(formatDate("2026-12-31T21:30:00Z")).toBe("01.01.2027");
|
||
expect(formatDate("2026-12-31T20:59:00Z")).toBe("31.12.2026");
|
||
});
|
||
|
||
it("tarih-saat biçimi", () => {
|
||
expect(norm(formatDateTime("2026-11-05T07:05:00Z"))).toBe("05.11.2026 10:05");
|
||
});
|
||
});
|