Team Ai
Apppublic

harshapitla/github-actions-analytics

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
App.test.js46 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 }}>{typeof children === "function" ? children({}) : children}</div>9  );10  return { ...actual, ResponsiveContainer };11});12 13jest.mock("./components/data/dataLoader", () => ({14  loadExtensionsCSV: jest.fn(),15}));16 17const mockRows = [18  {19    name: "Copilot",20    downloads_count: "1000000",21    reviews_count: "1200",22    rating: "4.7",23    publisher: "GitHub",24    categories: "AI",25    ai_enabled: true,26  },27];28 29beforeEach(() => {30  jest.clearAllMocks();31  loadExtensionsCSV.mockResolvedValue({ rows: mockRows });32});33 34test("renders dashboard chrome after dataset loads", async () => {35  render(<App />);36  expect(await screen.findByText(/VS Code Marketplace Insights/i)).toBeInTheDocument();37  expect(await screen.findByText(/Total Extensions/i)).toBeInTheDocument();38});39 40test("surfaces loader errors to the user", async () => {41  loadExtensionsCSV.mockRejectedValueOnce(new Error("boom"));42  render(<App />);43  expect(await screen.findByText(/Unable to load dataset/i)).toBeInTheDocument();44  expect(screen.getByRole("button", { name: /retry/i })).toBeInTheDocument();45});46