import { resolveSchemeCreatorName } from "./useSchemeCreatorName";

describe("resolveSchemeCreatorName", () => {
  it("shows the current viewer's display name for their own scheme", () => {
    expect(
      resolveSchemeCreatorName("tjwater", {
        username: "tjwater",
        name: "Test Account",
      }),
    ).toBe("Test Account");
  });

  it("keeps the stored username for another user's scheme", () => {
    expect(
      resolveSchemeCreatorName("operator", {
        username: "tjwater",
        name: "Test Account",
      }),
    ).toBe("operator");
  });

  it("falls back safely when identity data is incomplete", () => {
    expect(
      resolveSchemeCreatorName("tjwater", {
        username: "tjwater",
        name: " ",
      }),
    ).toBe("tjwater");
    expect(resolveSchemeCreatorName(undefined, undefined)).toBe("-");
  });
});
