feat(shared): zod şemaları, Türkçe arama ve TL/tarih biçimleri

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-05 01:35:10 +03:00
parent c875847b65
commit 4dbd2eb441
11 changed files with 504 additions and 3 deletions
+29
View File
@@ -0,0 +1,29 @@
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");
});
});