Files
butcem/src/shared/search.test.ts
T

39 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from "vitest";
import { compareTr, foldTr, includesTr } from "./search";
describe("foldTr", () => {
it("Türkçe harfleri ve büyük/küçük farkını normalize eder", () => {
expect(foldTr("İrem")).toBe("irem");
expect(foldTr("IŞIK")).toBe("isik");
expect(foldTr("Ayşe Çağrı Öztürk Ünal")).toBe("ayse cagri ozturk unal");
});
});
describe("includesTr", () => {
it("aksansız ve büyük harfli aramayla eşleşir", () => {
expect(includesTr("İrem Güneş", "irem")).toBe(true);
expect(includesTr("İrem Güneş", "GUNES")).toBe(true);
expect(includesTr("Ayşe", "ayse")).toBe(true);
expect(includesTr("Ayşe", "mehmet")).toBe(false);
});
it("boş arama her şeyle eşleşir, boş değer hiçbir aramayla eşleşmez", () => {
expect(includesTr("x", " ")).toBe(true);
expect(includesTr(undefined, "a")).toBe(false);
});
});
describe("compareTr", () => {
it("Türk alfabesine göre sıralar", () => {
expect(["Zeynep", "Çiğdem", "Can", "Şule", "Selin", "İrem", "Ilgın"].sort(compareTr)).toEqual([
"Can",
"Çiğdem",
"Ilgın",
"İrem",
"Selin",
"Şule",
"Zeynep",
]);
});
});