import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vitest";

import { CoinsRulesScreen } from "../coins-rules-screen";

vi.mock("@/stores/auth/auth-context", () => ({
  useAuthState: () => ({
    hasInitialized: true,
    isLoading: false,
    loginStatus: "email",
  }),
}));

vi.mock("@/stores/user/user-context", () => ({
  useUserDispatch: () => vi.fn(),
  useUserState: () => ({
    currentUser: {
      dailyFreeChatLimit: 30,
      dailyFreePrivateLimit: 2,
    },
  }),
}));

describe("CoinsRulesScreen", () => {
  it("renders outside CharacterProvider and returns to global profile", () => {
    const html = renderToStaticMarkup(
      <CoinsRulesScreen returnTo="/characters/maya/chat" />,
    );

    expect(html).toContain("Coin Usage Rules");
    expect(html).toContain(
      'href="/profile?returnTo=%2Fcharacters%2Fmaya%2Fchat"',
    );
  });
});
