Skip to content

Commit

Permalink
improve testcase for org card
Browse files Browse the repository at this point in the history
  • Loading branch information
AnshulKahar2729 committed Oct 31, 2024
1 parent 315641f commit 2b9d5bb
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();

Expand Down Expand Up @@ -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(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<OrganizationCard {...cardProps} />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

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,
Expand Down

0 comments on commit 2b9d5bb

Please sign in to comment.