import { describe, expect, it, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import Title from "@/components/doctor/detailDoctor/Title";
import ItemAppointment from "@/components/doctor/appointmentList/ItemAppointment";
vi.mock("@/components/doctor/detailDoctor/Share", () => ({ default: () => null }));
// همان شش تخصص دکتر محمدباقر جهانتاب.
const SPECIALTIES = [
{ id: "13", name: "جراحی عمومی", parent_id: null },
{ id: "14", name: "جراحی پلاستیک و زیبایی", parent_id: "13" },
{ id: "167", name: "جراحی لاپاراسکوپی", parent_id: "13" },
{ id: "168", name: "جراح تیروئید", parent_id: "13" },
{ id: "169", name: "جراح گوارش", parent_id: "13" },
{ id: "170", name: "جراحی سرطانها", parent_id: "13" },
];
const DOCTOR = { name: "محمدباقر جهانتاب", specialties: SPECIALTIES, experience: 5 };
describe("بدنهٔ پروفایل — فهرست کامل تخصصها", () => {
it("هر شش تخصص را جدا نشان میدهد، نه یک رشتهٔ درهم", () => {
render(
);
for (const s of SPECIALTIES) {
expect(screen.getByText(s.name)).toBeInTheDocument();
}
});
it("بعد از «تخصص:» نام نمیچسبد", () => {
// باگ قبلی: خروجی «تخصص:جراحی عمومی» بود.
render();
expect(screen.getByText("تخصص:")).toBeInTheDocument();
expect(screen.queryByText(/تخصص:جراحی/)).not.toBeInTheDocument();
});
it("جداکنندهٔ آویزان در انتها ندارد", () => {
const { container } = render();
expect(container.textContent).not.toMatch(/\|\s*$/);
expect(container.textContent).not.toContain("|");
});
it("پزشک بدون تخصص فقط برچسب را نشان میدهد و کرش نمیکند", () => {
expect(() =>
render()
).not.toThrow();
});
});
describe("ستون نوبتدهی — تخصص اصلی و شمارنده", () => {
const turn = { ...DOCTOR, uuid: "u-1", specialties: SPECIALTIES };
it("فقط تخصص اصلی و شمارندهٔ بقیه را نشان میدهد", () => {
render();
expect(screen.getByText(/جراحی عمومی/)).toBeInTheDocument();
expect(
screen.getByRole("button", { name: "نمایش 5 تخصص دیگر" })
).toBeInTheDocument();
expect(screen.queryByText("جراح گوارش")).not.toBeInTheDocument();
});
it("جداکنندهٔ آویزان ندارد", () => {
const { container } = render();
expect(container.textContent).not.toContain("|");
});
it("پزشک بدون تخصص کرش نمیکند", () => {
expect(() =>
render()
).not.toThrow();
});
});