From 2b9d5bb377734b5e64f701c1fc9eb10fa7944173 Mon Sep 17 00:00:00 2001 From: Anshul Kahar <22511126.dypit@dypvp.edu.in> Date: Thu, 31 Oct 2024 15:53:33 +0530 Subject: [PATCH 1/2] improve testcase for org card --- .../OrganizationCard.test.tsx | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx index 5546166b9a..b0bde9a14e 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx @@ -1,4 +1,4 @@ -import React, { act } from 'react'; +import React from 'react'; import { fireEvent, render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; @@ -19,6 +19,7 @@ import { JOIN_PUBLIC_ORGANIZATION, } from 'GraphQl/Mutations/OrganizationMutations'; import { toast } from 'react-toastify'; +import { act } from 'react-dom/test-utils'; const { getItem } = useLocalStorage(); @@ -225,6 +226,38 @@ describe('Testing OrganizationCard Component [User Portal]', () => { await wait(); }); + test('Visit organization', async () => { + const cardProps = { + ...props, + id: '3', + image: 'organizationImage', + userRegistrationRequired: true, + membershipRequestStatus: 'accepted', + }; + + render( + + + + + + + + + , + ); + + await wait(); + + expect(screen.getByTestId('manageBtn')).toBeInTheDocument(); + + fireEvent.click(screen.getByTestId('manageBtn')); + + await wait(); + + expect(window.location.pathname).toBe(`/user/organization/${cardProps.id}`); + }); + test('Send membership request', async () => { props = { ...props, From 0b9ac88aa94120e816e1ad223a3b90cad1e5c4aa Mon Sep 17 00:00:00 2001 From: Anshul Kahar <22511126.dypit@dypvp.edu.in> Date: Thu, 31 Oct 2024 16:05:18 +0530 Subject: [PATCH 2/2] act function warning --- .../UserPortal/OrganizationCard/OrganizationCard.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx index b0bde9a14e..1abaa44c65 100644 --- a/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx +++ b/src/components/UserPortal/OrganizationCard/OrganizationCard.test.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import { act } from '@testing-library/react'; import { fireEvent, render, screen } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { I18nextProvider } from 'react-i18next'; @@ -19,7 +20,6 @@ import { JOIN_PUBLIC_ORGANIZATION, } from 'GraphQl/Mutations/OrganizationMutations'; import { toast } from 'react-toastify'; -import { act } from 'react-dom/test-utils'; const { getItem } = useLocalStorage();