Skip to content

Commit

Permalink
test: should remove an already selected day when pressing it again
Browse files Browse the repository at this point in the history
  • Loading branch information
Natyrodrigues committed Sep 19, 2024
1 parent c42c39a commit 9f92f20
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/__tests__/weekDay.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,16 @@ describe("Testes para WeekDays", () => {
fireEvent.press(getByText("D"));
expect(mockCallbackFn).toHaveBeenCalledWith([EDiasSemana.Domingo]);
});

it("deve remover um dia já selecionado ao pressioná-lo novamente", () => {
const diasPredefinidos = [EDiasSemana.Domingo]; // Domingo já está selecionado
const mockCallbackFn = jest.fn();
const { getByText } = render(<WeekDays dias={diasPredefinidos} callbackFn={mockCallbackFn} />);

// Pressione o dia 'D' (Domingo), que já está selecionado
fireEvent.press(getByText("D"));

// Verifica se o callback foi chamado com o array vazio, removendo Domingo
expect(mockCallbackFn).toHaveBeenCalledWith([]);
});
});

0 comments on commit 9f92f20

Please sign in to comment.