From 12d92293f605e56276a0a87a620a65649be38371 Mon Sep 17 00:00:00 2001
From: Anvita Mahajan <78889572+Anvita0305@users.noreply.github.com>
Date: Sat, 10 Feb 2024 18:29:58 +0530
Subject: [PATCH] Modified test for src/components/CheckIn/CheckInWrapper.tsx
file (#1566)
* Modified Tests for CheckInWrapper file
* Update documentation
* Added tests
* Revert "Update documentation"
This reverts commit b79d09c0b0977a5934076143ee5b1deafa8ad68d.
* Update documentation
* Revert "Update documentation"
This reverts commit 5fc5098df25eefcbba0383f34d1ca87a904631f6.
* Update documentation
* Revert "Update documentation"
This reverts commit 47fbf2ca88b823527f6fc45eaf4370cfef173943.
---
src/components/CheckIn/CheckInModal.tsx | 2 +-
.../CheckIn/CheckInWrapper.test.tsx | 27 +++++++++----------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/src/components/CheckIn/CheckInModal.tsx b/src/components/CheckIn/CheckInModal.tsx
index 3f15824ecd..3a7813f4c9 100644
--- a/src/components/CheckIn/CheckInModal.tsx
+++ b/src/components/CheckIn/CheckInModal.tsx
@@ -80,7 +80,7 @@ export const CheckInModal = (props: InterfaceModalProp): JSX.Element => {
size="lg"
>
-
+
Event Check In Management
diff --git a/src/components/CheckIn/CheckInWrapper.test.tsx b/src/components/CheckIn/CheckInWrapper.test.tsx
index 9cb7fef4ba..a7c6a2025f 100644
--- a/src/components/CheckIn/CheckInWrapper.test.tsx
+++ b/src/components/CheckIn/CheckInWrapper.test.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { fireEvent, render, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import { CheckInWrapper } from './CheckInWrapper';
import { BrowserRouter } from 'react-router-dom';
@@ -21,7 +21,7 @@ describe('Testing CheckIn Wrapper', () => {
};
test('The button to open and close the modal should work properly', async () => {
- const { queryByText } = render(
+ render(
@@ -37,22 +37,19 @@ describe('Testing CheckIn Wrapper', () => {
);
// Open the modal
- fireEvent.click(queryByText('Check In Registrants') as Element);
+ fireEvent.click(screen.getByLabelText('checkInRegistrants') as Element);
await waitFor(() =>
- expect(queryByText('Event Check In Management')).toBeInTheDocument()
+ expect(screen.queryByTestId('modal-title')).toBeInTheDocument()
);
- /*
- TODO
- The following test of closing the modal should be uncommented when the memory leak issue of MUI Data Grid is fixed.
-
- It will consequently ensure 100% coverage of the file.
- */
- // Close the modal
- // fireEvent.click(queryByRole('button', { name: /close/i }) as HTMLElement);
- // await waitFor(() =>
- // expect(queryByText('Event Check In Management')).not.toBeInTheDocument()
- // );
+ // Close the modal
+ const closebtn = screen.getByLabelText('Close');
+
+ fireEvent.click(closebtn as Element);
+
+ await waitFor(() =>
+ expect(screen.queryByTestId('modal-title')).not.toBeInTheDocument()
+ );
});
});