2021-04-12 13:32:25 +00:00
|
|
|
import React from "react";
|
2022-03-28 18:50:40 +00:00
|
|
|
import { fireEvent, render, screen } from "@testing-library/react";
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
import ConfirmationPage from "components/forms/RegistrationForm/ConfirmationPage";
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
describe("ConfirmationPage - form", () => {
|
2016-11-16 16:58:25 +00:00
|
|
|
const formData = {
|
2022-12-22 20:24:13 +00:00
|
|
|
name: "Test User",
|
|
|
|
|
email: "test@example.com",
|
2021-06-24 20:42:29 +00:00
|
|
|
org_name: "Fleet",
|
2021-09-10 23:53:28 +00:00
|
|
|
server_url: "http://localhost:8080",
|
2016-11-16 16:58:25 +00:00
|
|
|
};
|
2022-03-28 18:50:40 +00:00
|
|
|
const handleSubmitSpy = jest.fn();
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
it("renders the user information", () => {
|
2022-03-28 18:50:40 +00:00
|
|
|
render(
|
|
|
|
|
<ConfirmationPage formData={formData} handleSubmit={handleSubmitSpy} />
|
2016-11-16 16:58:25 +00:00
|
|
|
);
|
|
|
|
|
|
2022-03-28 18:50:40 +00:00
|
|
|
expect(screen.getByText(formData.name)).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByText(formData.email)).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByText(formData.org_name)).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByText(formData.server_url)).toBeInTheDocument();
|
2016-11-16 16:58:25 +00:00
|
|
|
});
|
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
it("submits the form", () => {
|
2022-03-28 18:50:40 +00:00
|
|
|
render(
|
|
|
|
|
<ConfirmationPage
|
|
|
|
|
formData={formData}
|
|
|
|
|
handleSubmit={handleSubmitSpy}
|
|
|
|
|
currentPage
|
|
|
|
|
/>
|
2016-11-16 16:58:25 +00:00
|
|
|
);
|
|
|
|
|
|
2022-03-28 18:50:40 +00:00
|
|
|
fireEvent.click(screen.getByText("Confirm"));
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
|
expect(handleSubmitSpy).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
});
|