Fix hanging test and update README with resign feature

- Fix page.test.tsx: Use stable mock router reference to prevent infinite loop
  The useRouter mock was returning a new object on every render, causing
  the useEffect with router dependency to re-run infinitely
- Update README to document resign button and analyze game features
This commit is contained in:
Stefan
2025-12-03 08:56:33 +01:00
parent f9a245742b
commit 41ca7ae187
2 changed files with 11 additions and 4 deletions
+7 -3
View File
@@ -2,10 +2,13 @@
import { render, screen, fireEvent } from '@testing-library/react';
import Home from '../page';
const mockPush = jest.fn();
const mockRouter = {
push: mockPush,
};
jest.mock('next/navigation', () => ({
useRouter: () => ({
push: jest.fn(),
}),
useRouter: () => mockRouter,
}));
jest.mock('@/components/ChessGame', () => ({
@@ -27,6 +30,7 @@ jest.mock('@/components/StartScreen', () => ({
describe('Home Component', () => {
beforeEach(() => {
localStorage.setItem('gemini_api_key', 'test-key');
mockPush.mockClear();
});
it('renders the start screen initially', () => {