import "../../../tests/web/test-utils";
import { render } from "@testing-library/react";
import { describe, expect, test, vi } from "bun:test";

import type { HistoryResponse } from "../../../src/shared/api";

import { HistoryTab } from "../../../src/web/components/HistoryTab";

describe("HistoryTab", () => {
  const historyData: HistoryResponse = {
    items: [],
    page: 1,
    pageSize: 20,
    total: 0,
  };

  const onPageChange = vi.fn();

  test("渲染不崩溃", () => {
    const { container } = render(
      <HistoryTab historyData={historyData} historyLoading={false} onPageChange={onPageChange} />,
    );

    expect(container.firstChild).not.toBeNull();
  });

  test("loading 状态不崩溃", () => {
    const { container } = render(
      <HistoryTab historyData={historyData} historyLoading={true} onPageChange={onPageChange} />,
    );

    expect(container.firstChild).not.toBeNull();
  });

  test("空数据不崩溃", () => {
    const { container } = render(
      <HistoryTab historyData={historyData} historyLoading={false} onPageChange={onPageChange} />,
    );

    expect(container.firstChild).not.toBeNull();
  });
});
