Skip to content
Snippets Groups Projects
Commit b414b903 authored by HOLZINGER Ulysse's avatar HOLZINGER Ulysse
Browse files

Correction erreurs merge

parent 6c6fc8fa
No related branches found
No related tags found
No related merge requests found
Pipeline #26410 failed
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import Board from './Board';
import Board from '../components/Board';
test('renders the board with cells', () => {
const board = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]
];
const { container } = render(<Board board={board} handleClick={() => {}} />);
const cells = container.querySelectorAll('.cell');
expect(cells.length).toBe(6 * 7);
test('renders Board component', () => {
const board = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
render(<Board board={board} handleClick={() => {}} />);
});
test('calls handleClick when a cell is clicked', () => {
const board = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]
];
const handleClick = jest.fn();
const { getByTestId } = render(<Board board={board} handleClick={handleClick} />);
test('calls handleClick prop when a cell is clicked', () => {
const handleClickMock = jest.fn();
const board = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
const { container } = render(<Board board={board} handleClick={handleClickMock} />);
const cell = getByTestId('cell');
fireEvent.click(cell);
fireEvent.click(container.querySelector('.cell'));
expect(handleClick).toHaveBeenCalledWith(0); // Vérifie si handleClick est appelée avec le bon argument (0 pour la première cellule)
expect(handleClickMock).toHaveBeenCalledTimes(1);
});
import React from 'react';
import { render } from '@testing-library/react';
import Cell from './Cell';
import { render, fireEvent } from '@testing-library/react';
import Cell from '../components/Cell';
test('renders the cell with player 1 token', () => {
const { getByTestId } = render(<Cell value={1} />);
const tokenImage = getByTestId('player-1-token');
expect(tokenImage).toBeInTheDocument();
test('renders Cell component', () => {
render(<Cell value={0} onClick={() => {}} />);
});
test('renders the cell with player 2 token', () => {
const { getByTestId } = render(<Cell value={-1} />);
test('calls onClick prop when clicked', () => {
const onClickMock = jest.fn();
const { container } = render(<Cell value={0} onClick={onClickMock} />);
fireEvent.click(container.firstChild);
const tokenImage = getByTestId('player-2-token');
expect(tokenImage).toBeInTheDocument();
expect(onClickMock).toHaveBeenCalledTimes(1);
});
import React from 'react';
import { render, fireEvent, screen, queryByText, getByTestId } from '@testing-library/react';
import App from './App';
import App from '../App';
const { getAllByTestId, getByText } = screen;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment