Thinking.test.tsx (924B)
1 import { describe, it, expect, vi, beforeEach } from "vitest"; 2 import { render, screen, fireEvent } from "@testing-library/react"; 3 import { Thinking } from "./Thinking"; 4 5 beforeEach(() => { 6 // Mock scrollIntoView for jsdom 7 Element.prototype.scrollIntoView = vi.fn(); 8 }); 9 10 describe("Thinking", () => { 11 it("renders thinking label", () => { 12 render(<Thinking content="Let me think..." />); 13 expect(screen.getByText("Thinking")).toBeInTheDocument(); 14 }); 15 16 it("is collapsed by default", () => { 17 render(<Thinking content="Let me think about this problem carefully." />); 18 expect(screen.queryByText("Let me think about this problem carefully.")).not.toBeInTheDocument(); 19 }); 20 21 it("expands to show content on click", () => { 22 render(<Thinking content="Let me think..." />); 23 fireEvent.click(screen.getByText("Thinking")); 24 expect(screen.getByText("Let me think...")).toBeInTheDocument(); 25 }); 26 });