Skip to content

Commit

Permalink
Feat : Write Unittests for `src/components/UserPortal/OrganizationCar…
Browse files Browse the repository at this point in the history
…d/OrganizationCard.tsx` (#2393)

* improve testcase for org card

* act function warning
  • Loading branch information
AnshulKahar2729 authored Oct 31, 2024
1 parent e5f8a8b commit ed2a945
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { act } from 'react';
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';
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 ed2a945

Please sign in to comment.