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

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

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

describe("StatusBar", () => {
  const now = new Date().toISOString();

  const samples: RecentSample[] = [
    { durationMs: 100, timestamp: now, up: true },
    { durationMs: 150, timestamp: new Date(Date.now() - 60000).toISOString(), up: false },
  ];

  test("渲染不崩溃", () => {
    const { container } = render(<StatusBar maxSlots={5} samples={samples} />);
    expect(container.firstChild).not.toBeNull();
  });

  test("默认 maxSlots 不崩溃", () => {
    const { container } = render(<StatusBar samples={samples} />);
    expect(container.firstChild).not.toBeNull();
  });

  test("空 samples 不崩溃", () => {
    const { container } = render(<StatusBar maxSlots={3} samples={[]} />);
    expect(container.firstChild).not.toBeNull();
  });
});
