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:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user