import { expect, test } from "vitest"; import { screen } from "@testing-library/react"; import { renderApp } from "../test/render"; import { FlexibleFieldValue } from "./flexible-field-value"; import { fieldDefinitions } from "../test/fixtures"; function def(key: string) { return fieldDefinitions.find((d) => d.key === key)!; } test("term id resolves to its label", async () => { renderApp(); expect(await screen.findByText("Bronze")).toBeInTheDocument(); }); test("authority id resolves to its label", async () => { renderApp(); expect(await screen.findByText("Ada Lovelace")).toBeInTheDocument(); }); test("unknown term id renders (unknown)", async () => { renderApp(); expect(await screen.findByText(/t-missing\s*\(unknown\)/)).toBeInTheDocument(); }); test("localized_text picks the active language string", () => { renderApp( , ); expect(screen.getByText("Brons-amfora")).toBeInTheDocument(); expect(screen.queryByText("Bronze amphora")).not.toBeInTheDocument(); }); test("date is formatted, not the raw ISO string", () => { renderApp(); expect(screen.queryByText("2024-01-05")).not.toBeInTheDocument(); expect(screen.getByText(/Jan.*5.*2024/)).toBeInTheDocument(); }); test("boolean true renders Yes", () => { renderApp(); expect(screen.getByText("Yes")).toBeInTheDocument(); });