generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/'); | ||
}); | ||
}); | ||
}); |