Skip to content

Commit

Permalink
Corregidos errores tests temporizador
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289432 committed Apr 29, 2024
1 parent e284a38 commit 11c6a4c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions webapp/src/components/tests/Temporizador.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import Temporizador from '../Temporizador';
describe('Temporizador', () => {
it('renders the initial countdown time', () => {
const tiempoInicial = 60;
render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} />);
render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} setPausa={jest.fn()} />);
const countdownElement = screen.getByText(tiempoInicial);
expect(countdownElement).toBeInTheDocument();
});

it('decreases countdown time when not paused', () => {
jest.useFakeTimers();
const tiempoInicial = 60;
render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} />);
render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} setPausa={jest.fn()} />);
act(() => {
jest.advanceTimersByTime(1000);
});
Expand All @@ -24,7 +24,7 @@ describe('Temporizador', () => {
it('stops countdown time when paused', () => {
jest.useFakeTimers();
const tiempoInicial = 60;
render(<Temporizador tiempoInicial={tiempoInicial} pausa={true} />);
render(<Temporizador tiempoInicial={tiempoInicial} pausa={true} setPausa={jest.fn()} />);
act(() => {
jest.advanceTimersByTime(1000);
});
Expand All @@ -35,18 +35,18 @@ describe('Temporizador', () => {
it('restarts countdown time when restart prop changes', () => {
jest.useFakeTimers();
const tiempoInicial = 60;
const { rerender } = render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} />);
const { rerender } = render(<Temporizador tiempoInicial={tiempoInicial} pausa={false} setPausa={jest.fn()} />);
act(() => {
jest.advanceTimersByTime(1000);
});
const updatedCountdownElement = screen.getByText(tiempoInicial - 1);
expect(updatedCountdownElement).toBeInTheDocument();

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

// Countdown should restart
const restartedCountdownElement = screen.getByText(tiempoInicial);
expect(restartedCountdownElement).toBeInTheDocument();
});
});
});

0 comments on commit 11c6a4c

Please sign in to comment.