You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
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<string, string> = 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(<QuestionCard item={mockItem} />);
|
|
|
|
// 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(<QuestionCard item={item3Min} />);
|
|
|
|
// In Arabic: "تقدير الوقت: 3 دقائق"
|
|
expect(screen.getByText("تقدير الوقت: 3 دقائق")).toBeDefined();
|
|
});
|
|
|
|
it("translates '2 min' to Persian '۲ دقیقه' in Persian locale", () => {
|
|
mockDictionary = fa;
|
|
mockLocale = "fa";
|
|
|
|
render(<QuestionCard item={mockItem} />);
|
|
|
|
// In Persian: "زمان تقریبی: ۲ دقیقه"
|
|
expect(screen.getByText("زمان تقریبی: ۲ دقیقه")).toBeDefined();
|
|
});
|
|
});
|