Skip to content

Commit

Permalink
test: error message invalid value
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Monteiro <gabrielmonteiro1203@gmail.com>
Co-authored-by: Jessica Luiza Silva de Oliveira <jluiza409@gmail.com>
Co-authored-by: Marcella Sanderle <marcellasanderle@gmail.com>
  • Loading branch information
4 people committed Sep 20, 2024
1 parent 4eaf7d6 commit 250db3a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/app/__tests__/modalmetrica.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,29 @@ describe("ModalMetrica Component", () => {
expect(getByText("Campo obrigatório!")).toBeTruthy();
});
});

it("exibe mensagem de erro ao tentar salvar com formato inválido", async () => {
const { getByTestId, getByText } = render(
<ModalMetrica
visible={true}
callbackFn={() => {}}
closeModal={() => {}}
callbackValor={() => {}}
message="Teste"
metrica={mockItem}
/>,
);

// Supondo que haja um campo de entrada para o valor
const input = getByTestId("valorInput"); // Altere para o seu testID real do input
fireEvent.changeText(input, "abc123"); // Valor inválido

fireEvent.press(getByTestId("callbackBtn")); // Pressiona o botão para salvar

await waitFor(() => {
expect(getByText("Formato inválido!")).toBeTruthy(); // Verifica se a mensagem de erro está visível
});
});
});

});

0 comments on commit 250db3a

Please sign in to comment.