import { expect, test } from "vitest";

import { labelText } from "./labels";

const labels = [
  { lang: "en", label: "Bowl" },
  { lang: "sv", label: "Skål" },
];

test("returns the exact-language label when present", () => {
  expect(labelText(labels, "sv")).toBe("Skål");
});

test("falls back to the English label when the requested language is missing", () => {
  expect(labelText(labels, "de")).toBe("Bowl");
});

test("falls back to the first label when neither the language nor English is present", () => {
  expect(labelText([{ lang: "fr", label: "Bol" }], "de")).toBe("Bol");
});

test("returns an empty string for no labels", () => {
  expect(labelText([], "en")).toBe("");
});
