Skip to content

Commit

Permalink
Merge pull request #172 from Arquisoft/pablo
Browse files Browse the repository at this point in the history
Mejora de test
  • Loading branch information
uo264915 authored Apr 28, 2024
2 parents 68882fd + 90bbc44 commit 81c4c20
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
9 changes: 1 addition & 8 deletions webapp/src/components/HistoricalData.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import React, { useState, useEffect } from 'react';
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Container, TablePagination, Typography } from '@mui/material';
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Container, TablePagination, Typography, Snackbar } from '@mui/material';
import './HistoricalData.css';
import Navbar from './Navbar';

Expand Down Expand Up @@ -57,13 +57,6 @@ const HistoricalData = () => {
</TableRow>
</TableHead>
<TableBody>
{/* {paginatedData.map((row, rowIndex) => (
<TableRow key={rowIndex}>
{row.map((cell, cellIndex) => (
<TableCell key={cellIndex}>{cell}</TableCell>
))}
</TableRow>
))} */}
{paginatedData.map((row, rowIndex) => (
<TableRow key={rowIndex}>
<TableCell>{row[0]}</TableCell>
Expand Down
4 changes: 3 additions & 1 deletion webapp/src/components/HistoricalData.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import HistoricalData from './HistoricalData';
Expand Down Expand Up @@ -36,6 +36,8 @@ describe('HistoricalData component', () => {
expect(screen.getByText('Londres')).toBeInTheDocument();
expect(screen.getByText('Madrid')).toBeInTheDocument();
expect(screen.getByText('Roma')).toBeInTheDocument();

expect(screen.getByText('Rows per page:')).toBeInTheDocument();

});
});
Expand Down
28 changes: 26 additions & 2 deletions webapp/src/components/MainPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,39 @@ describe('MainPage component', () => {
const element1 = screen.getByText(/¡Bienvenido a/);
const element2 = screen.getByText(/WIQ 2024!/);
const newGameButton = screen.getByRole('button', { name: 'Nuevo juego' });
const rankingButton = screen.getByRole('button', { name: 'Ranking' });
const configButton = screen.getByRole('button', { name: 'Configuración' });

// Verifica si el elemento se encuentra en el DOM
expect(element1).toBeInTheDocument();
expect(element2).toBeInTheDocument();

// Simulate user input
await act(async () => {
fireEvent.click(newGameButton);
});

expect(window.location.pathname).toBe('/Game');

fireEvent.click(rankingButton);

expect(window.location.pathname).toBe('/ScoreBoard');

fireEvent.click(configButton);

const dialogTitle = screen.getByText('Configuración del juego');
expect(dialogTitle).toBeInTheDocument();

const numQuestionsInput = screen.getByLabelText('Número de preguntas (min. 5)');
const timePerQuestionInput = screen.getByLabelText('Tiempo por pregunta (mín. 10 segundos)');
const acceptButton = screen.getByRole('button', { name: 'Aceptar' });

expect(dialogTitle).toBeVisible();
expect(numQuestionsInput).toBeInTheDocument();
expect(timePerQuestionInput).toBeInTheDocument();
expect(acceptButton).toBeInTheDocument();

fireEvent.change(numQuestionsInput, { target: { value: '10' } });
fireEvent.change(timePerQuestionInput, { target: { value: '15' } });
fireEvent.click(acceptButton);
});
});

Expand Down

0 comments on commit 81c4c20

Please sign in to comment.