Skip to content

Commit

Permalink
Corregido error test temporizador
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289432 committed Apr 29, 2024
1 parent dd69b2a commit e284a38
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions webapp/src/components/tests/Temporizador.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Temporizador from '../Temporizador';
describe('Temporizador', () => {
it('renders the initial countdown time', () => {
const tiempoInicial = 60;
render(<Temporizador tiempoInicial={tiempoInicial} />);
render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} />);
const countdownElement = screen.getByText(tiempoInicial);
expect(countdownElement).toBeInTheDocument();
});
Expand Down Expand Up @@ -35,16 +35,15 @@ describe('Temporizador', () => {
it('restarts countdown time when restart prop changes', () => {
jest.useFakeTimers();
const tiempoInicial = 60;
const { rerender } = render(<Temporizador tiempoInicial={tiempoInicial} />);
const { rerender } = render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} />);
act(() => {
jest.advanceTimersByTime(1000);
});
const updatedCountdownElement = screen.getByText(tiempoInicial - 1);
expect(updatedCountdownElement).toBeInTheDocument();

// Simulate restart by changing the restart prop
rerender(<Temporizador tiempoInicial={tiempoInicial} restart={true}
handleRestart={jest.fn()} />);
rerender(<Temporizador tiempoInicial={tiempoInicial} pausa={false} restart={true} handleRestart={jest.fn()} />);

// Countdown should restart
const restartedCountdownElement = screen.getByText(tiempoInicial);
Expand Down

0 comments on commit e284a38

Please sign in to comment.