Skip to content

Commit

Permalink
test: Add test to ensure invalid hours are not allowed
Browse files Browse the repository at this point in the history
Co-Authored-By: Natalia Rodrigues <Natytotherodrigues@gmail.com>
  • Loading branch information
GabrielSMonteiro and Natyrodrigues committed Sep 20, 2024
1 parent 72184af commit 24588eb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/app/__tests__/MaskHour.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,32 @@ describe("MaskInput", () => {
// Verifica se inputMaskChange foi chamado com o valor mascarado correto
expect(mockInputMaskChange).toHaveBeenCalledWith("12:34");
});

test("não permite horas inválidas", () => {
const { getByTestId } = render(
<MaskInput inputMaskChange={mockInputMaskChange} testID="mask-input" />
);

const input = getByTestId("mask-input");

// Simula a mudança do texto
fireEvent.changeText(input, "9999");

// Verifica se inputMaskChange foi chamado com uma string vazia
expect(mockInputMaskChange).toHaveBeenCalledWith("");
});

test("verifica se o valor do input é atualizado corretamente", () => {
const { getByTestId } = render(
<MaskInput inputMaskChange={mockInputMaskChange} testID="mask-input" />
);

const input = getByTestId("mask-input");

// Simula a mudança do texto
fireEvent.changeText(input, "0959");

// Verifica se inputMaskChange foi chamado com o valor mascarado correto
expect(mockInputMaskChange).toHaveBeenCalledWith("09:59");
});
});

0 comments on commit 24588eb

Please sign in to comment.