import { describe, expect, it } from "vitest";

import { shouldShowFirstRechargeOfferBanner } from "../use-first-recharge-offer-banner";

describe("shouldShowFirstRechargeOfferBanner", () => {
  it("shows for authenticated users when first recharge offer is available", () => {
    expect(
      shouldShowFirstRechargeOfferBanner({
        historyLoaded: true,
        loginStatus: "facebook",
        isFirstRecharge: true,
        dismissed: false,
      }),
    ).toBe(true);
  });

  it("does not show for guest users", () => {
    expect(
      shouldShowFirstRechargeOfferBanner({
        historyLoaded: true,
        loginStatus: "guest",
        isFirstRecharge: true,
        dismissed: false,
      }),
    ).toBe(false);
  });

  it("does not show unless isFirstRecharge is true", () => {
    expect(
      shouldShowFirstRechargeOfferBanner({
        historyLoaded: true,
        loginStatus: "google",
        isFirstRecharge: false,
        dismissed: false,
      }),
    ).toBe(false);
  });

  it("does not show after the user dismisses it", () => {
    expect(
      shouldShowFirstRechargeOfferBanner({
        historyLoaded: true,
        loginStatus: "email",
        isFirstRecharge: true,
        dismissed: true,
      }),
    ).toBe(false);
  });

  it("waits until chat history has loaded", () => {
    expect(
      shouldShowFirstRechargeOfferBanner({
        historyLoaded: false,
        loginStatus: "email",
        isFirstRecharge: true,
        dismissed: false,
      }),
    ).toBe(false);
  });
});
