Skip to content

Commit

Permalink
Tests React salvo Game.js y organizado el directorio components
Browse files Browse the repository at this point in the history
  • Loading branch information
Santiago21112001 committed Mar 6, 2024
1 parent 858e20a commit 1246afa
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 10 deletions.
4 changes: 2 additions & 2 deletions webapp/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import AddUser from './components/AddUser';
import Login from './components/Login';
import AddUser from './components/adduser/AddUser';
import Login from './components/login/Login';
import CssBaseline from '@mui/material/CssBaseline';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
Expand Down
12 changes: 7 additions & 5 deletions webapp/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/WIQ_ES04C/i);
expect(linkElement).toBeInTheDocument();
describe('App Component', () => {
test('renders App component', () => {
render(<App />);
expect(screen.getByText(/Welcome to the 2024 edition of the Software Architecture course/i)).toBeInTheDocument();
});
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import '../styles/Footer.css'; // Asegúrate de importar tu archivo de estilos si es necesario
import './Footer.css'; // Asegúrate de importar tu archivo de estilos si es necesario

const Footer = () => (
<footer className="footer">
Expand Down
27 changes: 27 additions & 0 deletions webapp/src/components/footer/Footer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import Footer from './Footer';

describe('Footer Component', () => {
test('renders footer with correct content and links', () => {
// Renderizar el componente
render(<Footer />);

// Verificar que el texto "Trabajo de Arquitectura del Software" esté presente
expect(screen.getByText('Trabajo de Arquitectura del Software')).toBeInTheDocument();

// Verificar que el enlace al Github del Proyecto esté presente con el atributo target="_blank"
const githubLink = screen.getByRole('link', { name: /Github del Proyecto/i });
expect(githubLink).toBeInTheDocument();
expect(githubLink).toHaveAttribute('href', 'https://github.com/Arquisoft/wiq_es04c');
expect(githubLink).toHaveAttribute('target', '_blank');
expect(githubLink).toHaveAttribute('rel', 'noopener noreferrer');

// Verificar que el enlace a la Escuela de Ingeniería Informática esté presente con el atributo target="_blank"
const schoolLink = screen.getByRole('link', { name: /Escuela de Ingeniería Informática/i });
expect(schoolLink).toBeInTheDocument();
expect(schoolLink).toHaveAttribute('href', 'https://ingenieriainformatica.uniovi.es');
expect(schoolLink).toHaveAttribute('target', '_blank');
expect(schoolLink).toHaveAttribute('rel', 'noopener noreferrer');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useState } from 'react';
import axios from 'axios';
import { Container, Typography, TextField, Button, Snackbar } from '@mui/material';
import Game from './game/Game.js';
import Game from '../game/Game.js';

const Login = () => {
const [username, setUsername] = useState('');
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// En /src/components/Navbar.js
import React from 'react';
import '../styles/Navbar.css'; // Importa tu archivo de estilos si es necesario
import './Navbar.css'; // Importa tu archivo de estilos si es necesario

const Navbar = () => (
<nav className="navbar navbar-expand-lg navbar-dark bg-primary fixed-top">
Expand Down
33 changes: 33 additions & 0 deletions webapp/src/components/navbar/NavBar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import Navbar from './Navbar';

describe('Navbar Component', () => {
test('renders Navbar with correct content and links', () => {
// Renderizar el componente
render(<Navbar />);

// Verificar que el logo esté presente
const logo = screen.getByAltText('Logo');
expect(logo).toBeInTheDocument();
expect(logo).toHaveAttribute('src', '/LogoSaberYganar.png');

// Verificar que los enlaces de registro e inicio de sesión estén presentes con los íconos correctos
const registerLink = screen.getByRole('link', { name: /Registrarse/i });
expect(registerLink).toBeInTheDocument();
expect(registerLink).toHaveAttribute('href', '/signup');

const loginLink = screen.getByRole('link', { name: /Iniciar sesión/i });
expect(loginLink).toBeInTheDocument();
expect(loginLink).toHaveAttribute('href', '/login');

// Verificar que los íconos estén presentes en los enlaces
const registerIcon = screen.getByRole('link', { name: /Registrarse/i }).querySelector('i');
expect(registerIcon).toBeInTheDocument();
expect(registerIcon).toHaveClass('fas fa-sign-in-alt');

const loginIcon = screen.getByRole('link', { name: /Iniciar sesión/i }).querySelector('i');
expect(loginIcon).toBeInTheDocument();
expect(loginIcon).toHaveClass('fas fa-sign-in-alt');
});
});
File renamed without changes.

0 comments on commit 1246afa

Please sign in to comment.