Skip to content

Commit

Permalink
Test de NotFound.js
Browse files Browse the repository at this point in the history
  • Loading branch information
larafmz committed Apr 9, 2024
1 parent 57c9e6c commit 6f7ad63
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions webapp/src/components/Pages/NotFound.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import { render, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import NotFound from './NotFound';
import { BrowserRouter as Router } from 'react-router-dom';

jest.useFakeTimers();

describe('NotFound component', () => {
test('redirects to home page after a brief delay', async () => {
const { queryByText } = render(
<Router>
<NotFound />
</Router>
);

// Verifica que el mensaje de error 404 esté presente
expect(queryByText('404 - Página no encontrada')).toBeInTheDocument();

// Avanza en el tiempo para simular el retraso de redirección
jest.advanceTimersByTime(2000); // Avanza en el tiempo por 2 segundos

// Espera a que se redirija a la página de inicio
await waitFor(() => {
expect(window.location.pathname).toBe('/');
});
});
});

0 comments on commit 6f7ad63

Please sign in to comment.