reboot alterflixhub
This commit is contained in:
commit
1e84023a44
188 files changed
+31629
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
DEFAULT_CATEGORY,
|
||||
filterCinemas,
|
||||
findCinemaBySlug,
|
||||
listOtherCinemas,
|
||||
CINEMAS,
|
||||
} from "./cinemas";
|
||||
|
||||
describe("filterCinemas", () => {
|
||||
it("คืนทุกโรงหนังเมื่อเลือกหมวดทั้งหมดและไม่พิมพ์ค้นหา", () => {
|
||||
const result = filterCinemas(CINEMAS, { category: DEFAULT_CATEGORY, query: "" });
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("กรองตามหมวดหมู่จาก tags", () => {
|
||||
const result = filterCinemas(CINEMAS, { category: "อาร์ตเฮาส์", query: "" });
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
expect(result.every((cinema) => cinema.tags.includes("อาร์ตเฮาส์"))).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it("ค้นหาแบบไม่สนตัวพิมพ์และตัดช่องว่างหัวท้าย", () => {
|
||||
const result = filterCinemas(CINEMAS, {
|
||||
category: DEFAULT_CATEGORY,
|
||||
query: " house ",
|
||||
});
|
||||
expect(result.map((cinema) => cinema.slug)).toContain(
|
||||
"house-cinema-samyan",
|
||||
);
|
||||
});
|
||||
|
||||
it("คืนอาร์เรย์ว่างเมื่อไม่พบคำค้น", () => {
|
||||
expect(
|
||||
filterCinemas(CINEMAS, { category: DEFAULT_CATEGORY, query: "ไม่มีโรงนี้แน่นอน" }),
|
||||
).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("findCinemaBySlug", () => {
|
||||
it("คืน undefined เมื่อไม่ได้ส่ง slug", () => {
|
||||
expect(findCinemaBySlug(CINEMAS, undefined)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("คืนโรงหนังตาม slug", () => {
|
||||
expect(findCinemaBySlug(CINEMAS, "house-cinema-samyan")?.name).toBe(
|
||||
"HOUSE CINEMA SAMYAN",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("listOtherCinemas", () => {
|
||||
it("ไม่รวมโรงหนังปัจจุบันและไม่เกิน limit", () => {
|
||||
const others = listOtherCinemas(CINEMAS, "house-cinema-samyan", 4);
|
||||
expect(others).toHaveLength(4);
|
||||
expect(others.map((cinema) => cinema.slug)).not.toContain(
|
||||
"house-cinema-samyan",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user