i want you to fix this error. files are provided


 FAIL  src/components/joinGame/JoinGame.test.tsx > JoinGame Component > successfully joins a game
AssertionError: expected "spy" to be called with arguments: [ '/game-lobby/testGameId', …(1) ]

Received: 

  1st spy call:

  Array [
    "/game-lobby/testGameId",
-   Object {
-     "state": Object {
-       "gameCode": "ABC123",
-     },
-   },


--

import React from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { BrowserRouter } from 'react-router-dom';
import { vi } from 'vitest';
import JoinGame from './JoinGame';
import { httpsCallable } from 'firebase/functions';
import { ensureAnonymousAuth } from '../../firebase/auth/auth';
import usePlayerStore from '../../store/usePlayerStore';

// Mock the dependencies
vi.mock('firebase/functions');
vi.mock('../../firebase/auth/auth');
vi.mock('../../store/usePlayerStore');

const mockNavigate = vi.fn();
vi.mock('react-router-dom', async () => {
    const actual = await vi.importActual('react-router-dom');
    return {
        ...actual,
        useNavigate: () => mockNavigate,
    };
});

describe('JoinGame Component', () => {

    const mockJoinGame = vi.fn();

    beforeEach(() => {
        vi.clearAllMocks();
        (usePlayerStore as unknown as vi.Mock).mockReturnValue({ name: '', setName: vi.fn() });
        (httpsCallable as unknown as vi.Mock).mockReturnValue(mockJoinGame);
        (ensureAnonymousAuth as unknown as vi.Mock).mockResolvedValue(null);
    });

    it('renders game code input when player name is set', () => {
        (usePlayerStore as unknown as vi.Mock).mockReturnValue({ name: 'TestPlayer', setName: vi.fn() });

        render(
            <BrowserRouter>
                <JoinGame />
            </BrowserRouter>
        );

        expect(screen.getByText('Join a Game')).toBeInTheDocument();
        expect(screen.getByLabelText('Game Code')).toBeInTheDocument();
        expect(screen.getByRole('button', { name: 'Join Game' })).toBeInTheDocument();
    });

    it('validates game code format', async () => {
        render(
            <BrowserRouter>
                <JoinGame />
            </BrowserRouter>
        );

        const input = screen.getByLabelText('Game Code');
        const submitButton = screen.getByRole('button', { name: 'Join Game' });

        fireEvent.change(input, { target: { value: 'ABC12' } });
        fireEvent.click(submitButton);

        await waitFor(() => {
            expect(screen.getByText('Invalid game code. Please enter a 6-character alphanumeric code.')).toBeInTheDocument();
        });
    });

    it('successfully joins a game', async () => {
        (usePlayerStore as unknown as vi.Mock).mockReturnValue('TestPlayer');
        mockJoinGame.mockResolvedValue({ data: { gameId: 'testGameId' } });

        render(
            <BrowserRouter>
                <JoinGame />
            </BrowserRouter>
        );

        const input = screen.getByLabelText('Game Code');
        const submitButton = screen.getByRole('button', { name: 'Join Game' });

        fireEvent.change(input, { target: { value: 'ABC123' } });
        fireEvent.click(submitButton);

        await waitFor(() => {
            expect(ensureAnonymousAuth).toHaveBeenCalled();
            expect(mockJoinGame).toHaveBeenCalledWith({ gameCode: 'ABC123', playerName: 'TestPlayer' });
            expect(mockNavigate).toHaveBeenCalledWith('/game-lobby/testGameId', { state: { gameCode: 'ABC123' } });
        });
    });

    it('handles join game error', async () => {
        (httpsCallable as unknown as vi.Mock).mockReturnValue(() => Promise.reject(new Error('Game not found')));

        render(
            <BrowserRouter>
                <JoinGame />
            </BrowserRouter>
        );

        const input = screen.getByLabelText('Game Code');
        const submitButton = screen.getByRole('button', { name: 'Join Game' });

        fireEvent.change(input, { target: { value: 'ABC123' } });
        fireEvent.click(submitButton);

        await waitFor(() => {
            expect(screen.getByText('Game not found')).toBeInTheDocument();
        });
    });
});