Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
msveshnikov committed Mar 24, 2024
1 parent 76e4575 commit c20c340
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import React from "react";
import { render, fireEvent, waitFor, screen } from "@testing-library/react";
import App from "../../App";
import "@testing-library/jest-dom/extend-expect";

describe("App Component", () => {
it("renders without crashing", () => {
render(<App />);
});

it("opens authentication modal when authentication button is clicked", async () => {
const { getByTestId, getByText } = render(<App />);
const authButton = getByTestId("auth-button");
const { getByText, getByRole } = render(<App />);
const authButton = getByText("Sign In");

fireEvent.click(authButton);

await waitFor(() => {
expect(getByText("Authentication Form")).toBeInTheDocument();
expect(getByRole("heading", "Login")).toBeInTheDocument();
});
});

Expand All @@ -32,7 +33,7 @@ describe("App Component", () => {
});

it("submits input correctly", async () => {
const { getByTestId, getByText } = render(<App />);
const { getByText } = render(<App />);
const inputField = screen.getByLabelText("Enter your question");
const submitButton = getByText("Send");

Expand Down

0 comments on commit c20c340

Please sign in to comment.