Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.0 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import { normalizeLinkHref } from "./normalize-link-href";

describe("normalizeLinkHref", () => {
  it("adds https to bare domains", () => {
    expect(normalizeLinkHref(" andrje.sh ")).toBe("https://andrje.sh");
    expect(normalizeLinkHref("kaneo.app/docs?x=1")).toBe(
      "https://kaneo.app/docs?x=1",
    );
  });

  it("keeps links that already have a scheme or are relative", () => {
    expect(normalizeLinkHref("http://localhost:5173")).toBe(
      "http://localhost:5173",
    );
    expect(normalizeLinkHref("mailto:[email protected]")).toBe(
      "mailto:[email protected]",
    );
    expect(normalizeLinkHref("/dashboard")).toBe("/dashboard");
    expect(normalizeLinkHref("#notes")).toBe("#notes");
  });

  it("turns email addresses into mailto links", () => {
    expect(normalizeLinkHref("[email protected]")).toBe(
      "mailto:[email protected]",
    );
  });

  it("returns an empty string for blank input", () => {
    expect(normalizeLinkHref("   ")).toBe("");
  });
});