import { describe, it, expect, vi } from "vitest";
import { useIsPremium } from "./useIsPremium";

// useIsPremium now reads LicenseContext (was: useLicense). Mock the context hook.
vi.mock("../contexts/LicenseContext", () => ({
  useLicenseContext: vi.fn(),
}));

import { useLicenseContext } from "../contexts/LicenseContext";

const mockUseLicenseContext = vi.mocked(useLicenseContext);

describe("useIsPremium", () => {
  it('returns true when edition is "premium"', () => {
    mockUseLicenseContext.mockReturnValue({
      status: "ready",
      edition: "premium",
      features: [],
      info: null,
      error: null,
      validating: false,
      validationError: null,
      refresh: vi.fn(),
      submitKey: vi.fn(),
    });
    expect(useIsPremium()).toBe(true);
  });

  it('returns false when edition is "base"', () => {
    mockUseLicenseContext.mockReturnValue({
      status: "ready",
      edition: "base",
      features: [],
      info: null,
      error: null,
      validating: false,
      validationError: null,
      refresh: vi.fn(),
      submitKey: vi.fn(),
    });
    expect(useIsPremium()).toBe(false);
  });

  it('returns false when edition is "free"', () => {
    mockUseLicenseContext.mockReturnValue({
      status: "ready",
      edition: "free",
      features: [],
      info: null,
      error: null,
      validating: false,
      validationError: null,
      refresh: vi.fn(),
      submitKey: vi.fn(),
    });
    expect(useIsPremium()).toBe(false);
  });
});
