import { describe, expect, it } from "vitest";
import { tbdOr } from "./tbd.js";

describe("4.1.23-R: tbdOr fallback", () => {
  const t = (k: string) => (k === "SHARED.TBD" ? "Уточняется" : k);

  it("returns TBD string for null", () => {
    expect(tbdOr(null, t)).toBe("Уточняется");
  });

  it("returns TBD string for undefined", () => {
    expect(tbdOr(undefined, t)).toBe("Уточняется");
  });

  it("returns TBD string for empty string", () => {
    expect(tbdOr("", t)).toBe("Уточняется");
  });

  it("returns TBD string for whitespace-only string", () => {
    expect(tbdOr("   ", t)).toBe("Уточняется");
  });

  it("returns the value when non-empty string", () => {
    expect(tbdOr("A320", t)).toBe("A320");
  });

  it("returns numeric value as-is", () => {
    expect(tbdOr(42, t)).toBe(42);
  });

  it("returns non-string non-number values as-is", () => {
    const obj = { code: "MOW" };
    expect(tbdOr(obj, t)).toBe(obj);
  });

  it("returns 0 as-is (not treated as missing)", () => {
    expect(tbdOr(0, t)).toBe(0);
  });
});
