Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

1.2 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { derivePollInviteStatus, getPollInvitePath } from "./utils";

describe("derivePollInviteStatus", () => {
  it("is sent when nothing has happened", () => {
    expect(
      derivePollInviteStatus({ openedAt: null, participantId: null }),
    ).toBe("sent");
  });

  it("is opened once the invite link was followed", () => {
    expect(
      derivePollInviteStatus({
        openedAt: new Date("2026-09-03T10:00:00Z"),
        participantId: null,
      }),
    ).toBe("opened");
  });

  it("is responded once a participant is joined, even without an open", () => {
    expect(
      derivePollInviteStatus({ openedAt: null, participantId: "p1" }),
    ).toBe("responded");
  });

  it("responded wins over opened", () => {
    expect(
      derivePollInviteStatus({
        openedAt: new Date("2026-09-03T10:00:00Z"),
        participantId: "p1",
      }),
    ).toBe("responded");
  });
});

describe("getPollInvitePath", () => {
  it("builds the per invitee path the email and the host copy share", () => {
    expect(getPollInvitePath({ pollId: "poll1", token: "AbC123" })).toBe(
      "/invite/poll1?token=AbC123",
    );
  });
});