Skip to content

Commit 3c78610

Browse files
committed
test: improve coverage to 90.66% with 366 tests
- Add comprehensive test suites for UI components (compare, floating-dock, sparkles) - Enhance ReadmeViewer tests for markdown rendering edge cases - Fix Hero component terminal close tests - Improve TerminalPopup test coverage Coverage improvements: - Statements: 89.27% → 90.66% (+1.39%) - Branches: 90.29% → 92.34% (+2.05%) - Functions: 73.19% → 79.38% (+6.19%) - Lines: 89.27% → 90.66% (+1.39%) Test count: 321 → 366 tests (+45, +14%) All 22 test suites passing ✅
1 parent 5a8608e commit 3c78610

File tree

6 files changed

+1589
-6
lines changed

6 files changed

+1589
-6
lines changed

src/components/__tests__/Hero.test.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
2+
import userEvent from "@testing-library/user-event";
23
import Hero from "../Hero";
34
import { GitHubRepo } from "@/types";
45
import { ScrollTrigger } from "gsap/ScrollTrigger";
@@ -151,6 +152,64 @@ describe("Hero Component", () => {
151152
expect(document.body.style.overflow).toBe("unset");
152153
});
153154

155+
it("should handle terminal close with body overflow restoration", async () => {
156+
const user = userEvent.setup();
157+
158+
const { container } = render(
159+
<Hero repositories={mockRepositories} loading={false} />
160+
);
161+
162+
const terminalButton = container.querySelector(".btn-flip") as HTMLElement;
163+
expect(terminalButton).toBeInTheDocument();
164+
165+
// Click to open terminal
166+
await user.click(terminalButton);
167+
168+
// Wait for terminal to open
169+
await waitFor(() => {
170+
expect(
171+
screen.getByText(/Welcome to Rudra's Terminal!/i)
172+
).toBeInTheDocument();
173+
});
174+
175+
// Verify terminal opened state
176+
expect(
177+
screen.getByText(/Type !help for available commands/i)
178+
).toBeInTheDocument();
179+
});
180+
181+
it("should handle terminal opening and closing", async () => {
182+
const user = userEvent.setup();
183+
184+
const { container } = render(
185+
<Hero repositories={mockRepositories} loading={false} />
186+
);
187+
188+
const terminalButton = container.querySelector(".btn-flip") as HTMLElement;
189+
expect(terminalButton).toBeInTheDocument();
190+
191+
// Click to open terminal
192+
await user.click(terminalButton);
193+
194+
// Wait for terminal to open
195+
await waitFor(() => {
196+
expect(
197+
screen.getByText(/Welcome to Rudra's Terminal!/i)
198+
).toBeInTheDocument();
199+
});
200+
201+
// Close the terminal
202+
const closeButtons = screen.getAllByTitle(/Close and Clear History/i);
203+
await user.click(closeButtons[0]);
204+
205+
// Terminal should be closed
206+
await waitFor(() => {
207+
expect(
208+
screen.queryByText(/Welcome to Rudra's Terminal!/i)
209+
).not.toBeInTheDocument();
210+
});
211+
});
212+
154213
it("should render ContainerTextFlip with animated words", () => {
155214
const { container } = render(
156215
<Hero repositories={mockRepositories} loading={false} />

0 commit comments

Comments
 (0)