import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { VarroaRateLight } from "./varroa-rate-light";
import type { VarroaBands } from "@/lib/varroa/bands";
const BANDS: VarroaBands = {
day: "2026-08-10",
bands: {
NATURAL_MITE_FALL: {
method: "NATURAL_MITE_FALL",
unit: "MITES_PER_DAY",
yellowFrom: 5,
redAbove: 10,
reason: "NATURAL_FALL_SEASON",
youngColony: false,
},
},
postTreatmentUntil: null,
active: true,
};
describe("VarroaRateLight", () => {
it("keeps one status element while the content changes", () => {
const { rerender } = render();
const status = screen.getByRole("status");
expect(status).toHaveAttribute("aria-live", "polite");
expect(status).toBeEmptyDOMElement();
rerender();
expect(screen.getByRole("status")).toBe(status);
expect(status).toHaveTextContent("12,4 Milben/Tag – Kritisch (Grenze 10, LWG)");
rerender();
expect(screen.getByRole("status")).toBe(status);
expect(status).toHaveTextContent(/^3,0 Milben\/Tag$/);
expect(screen.getAllByRole("status")).toHaveLength(1);
});
it("names every state in words, not by colour alone", () => {
const { rerender } = render();
expect(screen.getByRole("status")).toHaveTextContent("Gut");
rerender();
expect(screen.getByRole("status")).toHaveTextContent("Achtung");
rerender(
,
);
expect(screen.getByRole("status")).toHaveTextContent("Behandlungseffekt – Nachkontrolle ab 16.08.");
});
it("shows only the value for a method without a band", () => {
render();
expect(screen.getByRole("status")).toHaveTextContent(/^2,4 %$/);
});
});