28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
import specialtiesData from "@/data/specialties.json";
|
|
import { isCategorySpecialty, isIndexableSpecialty } from "@/lib/specialtyIndexing";
|
|
|
|
const bySlug = (slug) => specialtiesData.find((item) => item.slug === slug);
|
|
|
|
describe("isCategorySpecialty", () => {
|
|
it("والدِ دارای زیرشاخهٔ فعال دسته است → noindex", () => {
|
|
expect(isCategorySpecialty(bySlug("internal-medicine"))).toBe(true);
|
|
});
|
|
|
|
it("زیرشاخه هرگز دسته نیست → index", () => {
|
|
expect(isCategorySpecialty(bySlug("gastroenterology"))).toBe(false);
|
|
expect(isIndexableSpecialty(bySlug("gastroenterology"))).toBe(true);
|
|
});
|
|
|
|
it("والدِ بدون زیرشاخه در عمل برگ است → index", () => {
|
|
expect(isCategorySpecialty(bySlug("general-practitioner"))).toBe(false);
|
|
expect(isIndexableSpecialty(bySlug("general-practitioner"))).toBe(true);
|
|
});
|
|
|
|
it("ورودی تهی امن است", () => {
|
|
expect(isCategorySpecialty(null)).toBe(false);
|
|
expect(isIndexableSpecialty(null)).toBe(false);
|
|
expect(isIndexableSpecialty(undefined)).toBe(false);
|
|
});
|
|
});
|