import { describe, expect, it } from "vitest";
import { shouldShowTrialUpsell } from "./TrialUpsellModal";

describe("shouldShowTrialUpsell", () => {
  it("does not show when trial has more than 7 days remaining", () => {
    expect(
      shouldShowTrialUpsell({
        isTrialExpired: false,
        activeSubscriptionPlan: null,
        isTemporaryUser: false,
        daysRemaining: 14,
      })
    ).toBe(false);
  });

  it("shows when trial is within reminder window and user has no subscription", () => {
    expect(
      shouldShowTrialUpsell({
        isTrialExpired: false,
        activeSubscriptionPlan: null,
        isTemporaryUser: false,
        daysRemaining: 3,
      })
    ).toBe(true);
  });

  it("does not show when trial is expired", () => {
    expect(
      shouldShowTrialUpsell({
        isTrialExpired: true,
        activeSubscriptionPlan: null,
        isTemporaryUser: false,
        daysRemaining: null,
      })
    ).toBe(false);
  });

  it("does not show when organization already has a paid subscription", () => {
    expect(
      shouldShowTrialUpsell({
        isTrialExpired: false,
        activeSubscriptionPlan: "team",
        isTemporaryUser: false,
        daysRemaining: 2,
      })
    ).toBe(false);
  });

  it("does not show for temporary users", () => {
    expect(
      shouldShowTrialUpsell({
        isTrialExpired: false,
        activeSubscriptionPlan: null,
        isTemporaryUser: true,
        daysRemaining: 2,
      })
    ).toBe(false);
  });
});
