fix(i18n): preserve inherited-name labels as untranslated data
This commit is contained in:
@@ -78,6 +78,12 @@ const match = {
|
||||
|
||||
beforeEach(() => jest.clearAllMocks());
|
||||
|
||||
test.each(["constructor", "toString", "__proto__"])("timeline preserves unknown category %s as a label", async category => {
|
||||
mockedApi.get.mockResolvedValue({ data: { ...timeline, categories: ["stage", category] } } as any);
|
||||
render(<ApplicationTimeline jobId={7} />);
|
||||
expect(await screen.findByRole("button", { name: category })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// ---------- Timeline ----------
|
||||
|
||||
test("timeline renders grouped days, milestones and readable summaries", async () => {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { localizeCompletenessLabel } from "./views/career/careerCompletenessLabels";
|
||||
|
||||
test.each(["constructor", "toString", "__proto__", "Custom section"])("preserves unknown completeness label %s as data", label => {
|
||||
const translate = jest.fn(() => "translated");
|
||||
expect(localizeCompletenessLabel(label, translate)).toBe(label);
|
||||
expect(translate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("translates a known completeness label using its catalogue key", () => {
|
||||
const translate = jest.fn(() => "Personopplysninger");
|
||||
expect(localizeCompletenessLabel("Personal details", translate)).toBe("Personopplysninger");
|
||||
expect(translate).toHaveBeenCalledWith("profileCvCompletenessPersonal");
|
||||
});
|
||||
@@ -364,7 +364,7 @@ function timelineCategoryLabel(t: (key: any) => string, category: string): strin
|
||||
communication: "intelligenceCategoryCommunication",
|
||||
ai: "intelligenceCategoryAi",
|
||||
};
|
||||
return keys[category] ? t(keys[category]) : category;
|
||||
return Object.hasOwn(keys, category) ? t(keys[category]) : category;
|
||||
}
|
||||
|
||||
function matchBandLabel(t: (key: any) => string, band?: string): string {
|
||||
|
||||
@@ -11,6 +11,6 @@ const completenessLabelKeys: Record<string, TranslationKey> = {
|
||||
};
|
||||
|
||||
export function localizeCompletenessLabel(label: string, t: (key: TranslationKey) => string) {
|
||||
const key = completenessLabelKeys[label];
|
||||
const key = Object.hasOwn(completenessLabelKeys, label) ? completenessLabelKeys[label] : undefined;
|
||||
return key ? t(key) : label;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user