49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { Colors } from "~/application/enums/shared/Colors";
|
|
import RowSelectedOptionCell from "./RowSelectedOptionCell";
|
|
|
|
const translations: Record<string, string> = {
|
|
"models.contact.status.options.customer": "Kunde",
|
|
};
|
|
|
|
vi.mock("react-i18next", () => ({
|
|
useTranslation: () => ({
|
|
t: (key: string) => translations[key] ?? key,
|
|
i18n: {
|
|
exists: (key: string) => key in translations,
|
|
},
|
|
}),
|
|
}));
|
|
|
|
describe("RowSelectedOptionCell", () => {
|
|
it("renders seed select option labels through model translation fallbacks", () => {
|
|
render(
|
|
<RowSelectedOptionCell
|
|
value="customer"
|
|
entityName="contact"
|
|
propertyName="status"
|
|
display="Name"
|
|
options={[{ value: "customer", name: "Customer", color: Colors.GREEN }]}
|
|
/>
|
|
);
|
|
|
|
expect(screen.getByText("Kunde")).toBeTruthy();
|
|
expect(screen.queryByText("Customer")).toBeNull();
|
|
});
|
|
|
|
it("keeps custom option labels literal when no model translation exists", () => {
|
|
render(
|
|
<RowSelectedOptionCell
|
|
value="vip"
|
|
entityName="contact"
|
|
propertyName="status"
|
|
display="Name"
|
|
options={[{ value: "vip", name: "VIP customer", color: Colors.YELLOW }]}
|
|
/>
|
|
);
|
|
|
|
expect(screen.getByText("VIP customer")).toBeTruthy();
|
|
});
|
|
});
|