import { describe, test, expect } from "bun:test";
import { redactGitRemoteUrl } from "@/utils/git-remote.js";

describe("redactGitRemoteUrl", () => {
  test("SSH URL passes through unchanged", () => {
    expect(redactGitRemoteUrl("git@github.com:org/repo.git")).toBe("git@github.com:org/repo.git");
  });

  test("HTTPS URL with embedded credentials is redacted", () => {
    expect(redactGitRemoteUrl("https://user:token@github.com/org/repo.git")).toBe(
      "https://github.com/org/repo.git",
    );
  });

  test("HTTPS URL without credentials passes through unchanged", () => {
    expect(redactGitRemoteUrl("https://github.com/org/repo.git")).toBe(
      "https://github.com/org/repo.git",
    );
  });

  test("empty string returns empty string", () => {
    expect(redactGitRemoteUrl("")).toBe("");
  });

  test('literal "unknown" returns "unknown"', () => {
    expect(redactGitRemoteUrl("unknown")).toBe("unknown");
  });

  test("non-URL gibberish passes through unchanged", () => {
    expect(redactGitRemoteUrl("hello world")).toBe("hello world");
  });
});
