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.3 KB
Raw Blame
import { describe, expect, it } from "vite-plus/test";
import {
  hashTrialEmail,
  normalizeTrialEmail,
} from "../../../apps/api/src/billing/trial-identity";

describe("normalizeTrialEmail", () => {
  it("lowercases and trims", () => {
    expect(normalizeTrialEmail("  [email protected] ")).toBe("[email protected]");
  });

  it("drops plus tags so aliases share one trial", () => {
    expect(normalizeTrialEmail("[email protected]")).toBe(
      "[email protected]",
    );
  });

  it("keeps the address when stripping would empty the local part", () => {
    expect(normalizeTrialEmail("[email protected]")).toBe("[email protected]");
  });

  it("leaves values without an address shape alone", () => {
    expect(normalizeTrialEmail("not-an-email")).toBe("not-an-email");
  });
});

describe("hashTrialEmail", () => {
  it("matches for addresses that normalize to the same mailbox", () => {
    expect(hashTrialEmail("[email protected]")).toBe(
      hashTrialEmail("[email protected]"),
    );
  });

  it("differs for different mailboxes", () => {
    expect(hashTrialEmail("[email protected]")).not.toBe(
      hashTrialEmail("[email protected]"),
    );
  });

  it("does not store the address itself", () => {
    expect(hashTrialEmail("[email protected]")).not.toContain("kaneo");
  });
});