Skip to content

Commit

Permalink
Patient Details Modal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblurie29 committed Feb 16, 2024
1 parent 21b79f1 commit 1ba3a62
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const Modal = (props: ModalProps) => {
{props.header != null && (
<div className={styles.ModalHeaderText}>{props.header}</div>
)}
<div onClick={props.action} className={styles.ModalHeaderClose}>
<div
onClick={props.action}
className={styles.ModalHeaderClose}
data-testid="modal-close"
>
<div className={styles.ModalCircle}>
<Icon glyph="times" />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { createTestPassengerData } from "../../../../../util/test-data.util";
import PatientDetailsModal from "../PatientDetailsModal";
import { render, fireEvent } from "@testing-library/react";

describe("PatientDetailsModal", () => {
const mockOnClose = jest.fn();
const mockPatient = createTestPassengerData();

it("renders patient details correctly", () => {
const { getByText } = render(
<PatientDetailsModal patient={mockPatient} onClose={mockOnClose} />,
);

expect(getByText("Gender")).toBeTruthy();
expect(getByText(mockPatient.fields.Gender)).toBeTruthy();
expect(getByText("DOB")).toBeTruthy();
expect(
getByText(mockPatient.fields["Date of Birth"].split("T")[0]),
).toBeTruthy();
// Add similar checks for other fields
});

it("calls onClose when the modal action is triggered", () => {
const component = render(
<PatientDetailsModal patient={mockPatient} onClose={mockOnClose} />,
);

fireEvent.click(component.getByTestId("modal-close")); // Assuming the action triggers on a button click

expect(mockOnClose).toHaveBeenCalled();
});
});

0 comments on commit 1ba3a62

Please sign in to comment.