CoolFace
Apppublic

harshapitla/stackoverflow

sourceHugging Facemitupdated 9mo agoView on Hugging Face
0likes
App.test.js50 linesDownload Raw Back to src
1import { render, screen } from "@testing-library/react";2import App from "./App";3import { loadExtensionsCSV } from "./components/data/dataLoader";4 5jest.mock("recharts", () => {6  const actual = jest.requireActual("recharts");7  const ResponsiveContainer = ({ width = 800, height = 400, children }) => (8    <div style={{ width, height }}>9      {typeof children === "function" ? children({}) : children}10    </div>11  );12  return { ...actual, ResponsiveContainer };13});14 15jest.mock("./components/data/dataLoader", () => ({16  loadExtensionsCSV: jest.fn(),17}));18 19const mockRows = [20  {21    name: "Copilot",22    downloads_count: "1000000",23    reviews_count: "1200",24    rating: "4.7",25    publisher: "GitHub",26    categories: "AI",27    ai_enabled: true,28  },29];30 31beforeEach(() => {32  jest.clearAllMocks();33  loadExtensionsCSV.mockResolvedValue({ rows: mockRows });34});35 36test("renders dashboard chrome after dataset loads", async () => {37  render(<App />);38  expect(39    await screen.findByText(/GitHub Actions Marketplace Insights/i)40  ).toBeInTheDocument();41  expect(await screen.findByText(/Software Popularity/i)).toBeInTheDocument();42});43 44test("surfaces loader errors to the user", async () => {45  loadExtensionsCSV.mockRejectedValueOnce(new Error("boom"));46  render(<App />);47  expect(await screen.findByText(/Dataset load failed/i)).toBeInTheDocument();48  expect(screen.getByRole("button", { name: /retry/i })).toBeInTheDocument();49});50