From 45735f2eb955c150bc2973e2dfa5c974441fedd5 Mon Sep 17 00:00:00 2001 From: Rajat yadav Date: Fri, 26 Dec 2025 23:28:49 +0530 Subject: [PATCH] test: add App component test coverage Covers routing structure and component rendering behavior --- frontend/src/__tests__/App.test.tsx | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 frontend/src/__tests__/App.test.tsx diff --git a/frontend/src/__tests__/App.test.tsx b/frontend/src/__tests__/App.test.tsx new file mode 100644 index 00000000..ee1b41e5 --- /dev/null +++ b/frontend/src/__tests__/App.test.tsx @@ -0,0 +1,47 @@ +import { render, screen } from '@testing-library/react'; +import App from '../App'; + +jest.mock('../components/HomePage', () => ({ + HomePage: () =>
Home Page
, +})); + +jest.mock('../components/LandingPage', () => ({ + LandingPage: () =>
Landing Page
, +})); + +Object.defineProperty(window, 'location', { + value: { + href: 'http://localhost:3000/', + origin: 'http://localhost:3000', + pathname: '/', + }, + writable: true, +}); + +describe('App', () => { + it('renders without crashing', () => { + render(); + expect(document.body).toBeInTheDocument(); + }); + + it('contains BrowserRouter with future flags', () => { + const { container } = render(); + expect(container.firstChild).toBeInTheDocument(); + }); + + it('renders Routes component', () => { + render(); + expect(screen.getByTestId('landing-page')).toBeInTheDocument(); + }); + + it('has correct route structure', () => { + const routes = [ + { path: '/', element: 'LandingPage' }, + { path: '/home', element: 'HomePage' }, + ]; + + expect(routes).toHaveLength(2); + expect(routes[0].path).toBe('/'); + expect(routes[1].path).toBe('/home'); + }); +});