import { describe, expect, it } from "vitest";
import { buildCompanyAssetKey, buildSignatureKey } from "@/lib/storage";

describe("buildCompanyAssetKey", () => {
  it("builds a deterministic logo key under the company namespace", () => {
    expect(buildCompanyAssetKey("cmp123", "logo", "png")).toBe("company-assets/cmp123/logo.png");
  });

  it("builds a deterministic stamp key", () => {
    expect(buildCompanyAssetKey("cmp123", "stamp", "webp")).toBe("company-assets/cmp123/stamp.webp");
  });

  it("is stable across re-uploads of the same type (overwrites in place)", () => {
    const a = buildCompanyAssetKey("c1", "logo", "png");
    const b = buildCompanyAssetKey("c1", "logo", "png");
    expect(a).toBe(b);
  });

  it("separates logo and stamp into distinct keys", () => {
    expect(buildCompanyAssetKey("c1", "logo", "png")).not.toBe(buildCompanyAssetKey("c1", "stamp", "png"));
  });
});

describe("buildSignatureKey", () => {
  it("keeps signatures in their own namespace", () => {
    expect(buildSignatureKey("u1", "png")).toBe("signatures/u1.png");
  });
});
