// @vitest-environment jsdom
import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { DaysOfWeekStrip } from "./DaysOfWeekStrip.js";

vi.mock("@/i18n/provider.js", () => ({
  useTranslation: () => ({ t: (k: string) => k }),
}));

describe("DaysOfWeekStrip", () => {
  it("renders 7 day boxes", () => {
    render(<DaysOfWeekStrip flightBitString="1111111" />);
    const boxes = screen.getAllByTestId(/^day-of-week-\d$/);
    expect(boxes).toHaveLength(7);
  });

  it("marks first 3 active, last 4 inactive for '1110000'", () => {
    render(<DaysOfWeekStrip flightBitString="1110000" />);
    expect(screen.getByTestId("day-of-week-0").className).not.toMatch(/--inactive/);
    expect(screen.getByTestId("day-of-week-1").className).not.toMatch(/--inactive/);
    expect(screen.getByTestId("day-of-week-2").className).not.toMatch(/--inactive/);
    expect(screen.getByTestId("day-of-week-3").className).toMatch(/--inactive/);
    expect(screen.getByTestId("day-of-week-6").className).toMatch(/--inactive/);
  });

  it("marks all active for '1111111'", () => {
    render(<DaysOfWeekStrip flightBitString="1111111" />);
    for (let i = 0; i < 7; i++) {
      expect(screen.getByTestId(`day-of-week-${i}`).className).not.toMatch(/--inactive/);
    }
  });

  it("marks all inactive for '0000000'", () => {
    render(<DaysOfWeekStrip flightBitString="0000000" />);
    for (let i = 0; i < 7; i++) {
      expect(screen.getByTestId(`day-of-week-${i}`).className).toMatch(/--inactive/);
    }
  });

  it("renders DAYS.1 through DAYS.7 labels in order", () => {
    render(<DaysOfWeekStrip flightBitString="1111111" />);
    expect(screen.getByTestId("day-of-week-0").textContent).toContain("DAYS.1");
    expect(screen.getByTestId("day-of-week-6").textContent).toContain("DAYS.7");
  });
});
