From 3e9039cec50306511d73e8ed0759e5c99d56d905 Mon Sep 17 00:00:00 2001 From: Jamari McFarlane Date: Tue, 14 Nov 2023 01:43:54 -0500 Subject: [PATCH] fixed OrgListCard tests --- .../OrgListCard/OrgListCard.test.tsx | 62 +++++++++++++------ src/screens/OrgList/OrgList.tsx | 11 +++- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/components/OrgListCard/OrgListCard.test.tsx b/src/components/OrgListCard/OrgListCard.test.tsx index b7ba9db776..ffcf92981f 100644 --- a/src/components/OrgListCard/OrgListCard.test.tsx +++ b/src/components/OrgListCard/OrgListCard.test.tsx @@ -8,6 +8,24 @@ import type { InterfaceOrgListCardProps } from './OrgListCard'; import OrgListCard from './OrgListCard'; import userEvent from '@testing-library/user-event'; import { BrowserRouter } from 'react-router-dom'; +import { IS_SAMPLE_ORGANIZATION_QUERY } from 'GraphQl/Queries/Queries'; +import { StaticMockLink } from 'utils/StaticMockLink'; +import { MockedProvider } from '@apollo/react-testing'; + +const MOCKS = [ + { + request: { + query: IS_SAMPLE_ORGANIZATION_QUERY, + }, + result: { + data: { + isSampleOrganization: true, + }, + }, + }, +]; + +const link = new StaticMockLink(MOCKS, true); const props: InterfaceOrgListCardProps = { data: { @@ -38,11 +56,13 @@ describe('Testing the Super Dash List', () => { localStorage.setItem('id', '123'); // Means the user is an admin render( - - - - - + + + + + + + ); expect(screen.getByAltText(/Dogs Care image/i)).toBeInTheDocument(); expect(screen.getByText('Admins:')).toBeInTheDocument(); @@ -56,11 +76,13 @@ describe('Testing the Super Dash List', () => { window.location.assign('/orgdash'); render( - - - - - + + + + + + + ); expect(window.location).toBeAt('/orgdash'); @@ -72,20 +94,24 @@ describe('Testing the Super Dash List', () => { ...{ data: { ...props.data, ...{ image: null } } }, }; render( - - - + + + + + ); expect(screen.getByTestId(/emptyContainerForImage/i)).toBeInTheDocument(); }); test('Testing if user is redirected to orgDash screen', () => { render( - - - - - + + + + + + + ); userEvent.click(screen.getByTestId('manageBtn')); expect(window.location).toBeAt('/orgdash/id=xyz'); diff --git a/src/screens/OrgList/OrgList.tsx b/src/screens/OrgList/OrgList.tsx index 126b49314d..4b151d65e5 100644 --- a/src/screens/OrgList/OrgList.tsx +++ b/src/screens/OrgList/OrgList.tsx @@ -152,7 +152,7 @@ function orgList(): JSX.Element { toast.success(t('successMessage')); window.location.reload(); }) - .catch((error: any) => { + .catch(() => { toast.error(t('sampleOrgDuplicate')); }); }; @@ -413,7 +413,7 @@ function orgList(): JSX.Element { ))} ) : userData && userData.user.userType == 'SUPERADMIN' ? ( - orgsData?.organizationsConnection.map((item, index) => { + orgsData?.organizationsConnection.map((item) => { return (
@@ -610,6 +610,13 @@ function orgList(): JSX.Element { }} > +

{t('manageFeaturesInfo')}