import { render, waitFor } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";

const riveMocks = vi.hoisted(() => {
  const bindViewModelInstance = vi.fn();
  return {
    bindViewModelInstance,
    useRive: vi.fn(() => ({
      rive: { bindViewModelInstance },
      RiveComponent: () => <canvas aria-label="Rive Persona" />
    }))
  };
});

vi.mock("@rive-app/react-webgl2", () => ({
  useRive: riveMocks.useRive,
  useStateMachineInput: () => null
}));

import { Persona } from "./persona";

describe("Persona", () => {
  it("loads Obsidian without binding the Rive View Model", async () => {
    render(<Persona />);

    await waitFor(() =>
      expect(riveMocks.useRive).toHaveBeenCalledWith(
        expect.objectContaining({
          src: "https://ejiidnob33g9ap1r.public.blob.vercel-storage.com/obsidian-2.0.riv",
          stateMachines: "default"
        })
      )
    );
    expect(riveMocks.bindViewModelInstance).not.toHaveBeenCalled();
  });
});
