Initial commit
This commit is contained in:
		
							
								
								
									
										43
									
								
								frontend/src/App.test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								frontend/src/App.test.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | ||||
| import React from 'react'; | ||||
| import { render, screen } from '@testing-library/react'; | ||||
| import App from './App'; | ||||
|  | ||||
| // Mock the AuthContext | ||||
| jest.mock('./contexts/AuthContext', () => ({ | ||||
|   useAuth: () => ({ | ||||
|     user: null, | ||||
|     loading: false, | ||||
|     login: jest.fn(), | ||||
|     register: jest.fn(), | ||||
|     logout: jest.fn(), | ||||
|     fetchUser: jest.fn() | ||||
|   }), | ||||
|   AuthProvider: ({ children }) => children | ||||
| })); | ||||
|  | ||||
| // Mock react-router-dom | ||||
| jest.mock('react-router-dom', () => ({ | ||||
|   BrowserRouter: ({ children }) => <div>{children}</div>, | ||||
|   Routes: ({ children }) => <div>{children}</div>, | ||||
|   Route: ({ children }) => <div>{children}</div>, | ||||
|   Navigate: ({ to }) => <div data-testid="navigate">{to}</div>, | ||||
|   Outlet: () => <div data-testid="outlet">Outlet</div> | ||||
| })); | ||||
|  | ||||
| // Mock react-query | ||||
| jest.mock('react-query', () => ({ | ||||
|   QueryClient: jest.fn(() => ({})), | ||||
|   QueryClientProvider: ({ children }) => <div>{children}</div> | ||||
| })); | ||||
|  | ||||
| // Mock react-hot-toast | ||||
| jest.mock('react-hot-toast', () => ({ | ||||
|   Toaster: () => <div data-testid="toaster">Toaster</div> | ||||
| })); | ||||
|  | ||||
| describe('App', () => { | ||||
|   it('renders without crashing', () => { | ||||
|     render(<App />); | ||||
|     expect(screen.getByTestId('toaster')).toBeInTheDocument(); | ||||
|   }); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user