import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import QuestionCard from "./question-card"; import type { QuestionListItem } from "@/lib/schema-adapter"; import ar from "@/translations/locales/ar.json"; import fa from "@/translations/locales/fa.json"; let mockDictionary: Record = ar; let mockLocale = "ar"; vi.mock("@/translations/provider", () => ({ useI18n: () => ({ dictionary: mockDictionary, locale: mockLocale, }), })); const mockItem: QuestionListItem = { slug: "personal_identity", title: "البيانات الشخصية والتعريفية", estimate: "2 min", progress: 100, icon: "profile", required: true, summary: "", checkpoints: [], questions: [], }; describe("QuestionCard - Time Estimate Localization", () => { it("translates '2 min' to Arabic '2 دقيقة' in Arabic locale", () => { mockDictionary = ar; mockLocale = "ar"; render(); // In Arabic: "تقدير الوقت: 2 دقيقة" expect(screen.getByText("تقدير الوقت: 2 دقيقة")).toBeDefined(); }); it("translates '3 min' to Arabic '3 دقائق' in Arabic locale", () => { mockDictionary = ar; mockLocale = "ar"; const item3Min: QuestionListItem = { ...mockItem, title: "التعليم، والمهنة، والوضع المالي", estimate: "3 min", }; render(); // In Arabic: "تقدير الوقت: 3 دقائق" expect(screen.getByText("تقدير الوقت: 3 دقائق")).toBeDefined(); }); it("translates '2 min' to Persian '۲ دقیقه' in Persian locale", () => { mockDictionary = fa; mockLocale = "fa"; render(); // In Persian: "زمان تقریبی: ۲ دقیقه" expect(screen.getByText("زمان تقریبی: ۲ دقیقه")).toBeDefined(); }); });