import { describe, it, expect } from "vitest"; import { render, screen } from "@testing-library/react"; import { AudioVisualizer } from "./AudioVisualizer"; describe("AudioVisualizer", (): void => { it("should render the visualizer container", (): void => { render(); const container = screen.getByTestId("audio-visualizer"); expect(container).toBeInTheDocument(); }); it("should render visualization bars", (): void => { render(); const bars = screen.getAllByTestId("visualizer-bar"); expect(bars.length).toBeGreaterThan(0); }); it("should show inactive state when not active", (): void => { render(); const container = screen.getByTestId("audio-visualizer"); expect(container).toBeInTheDocument(); // Bars should be at minimum height when inactive const bars = screen.getAllByTestId("visualizer-bar"); bars.forEach((bar) => { const style = bar.getAttribute("style"); expect(style).toContain("height"); }); }); it("should reflect audio level in bar heights when active", (): void => { render(); const bars = screen.getAllByTestId("visualizer-bar"); // At least one bar should have non-minimal height const hasActiveBars = bars.some((bar) => { const style = bar.getAttribute("style") ?? ""; const heightMatch = /height:\s*(\d+)/.exec(style); return heightMatch?.[1] ? parseInt(heightMatch[1], 10) > 4 : false; }); expect(hasActiveBars).toBe(true); }); it("should use calm colors (no aggressive reds)", (): void => { render(); const container = screen.getByTestId("audio-visualizer"); const allElements = container.querySelectorAll("*"); allElements.forEach((el) => { const className = (el as HTMLElement).className; expect(className).not.toMatch(/bg-red-|text-red-/); }); }); it("should accept custom className", (): void => { render(); const container = screen.getByTestId("audio-visualizer"); expect(container.className).toContain("custom-class"); }); it("should render with configurable bar count", (): void => { render(); const bars = screen.getAllByTestId("visualizer-bar"); expect(bars).toHaveLength(8); }); });