Skip to content

Commit

Permalink
Test for OrgListCard.tsx (#1891)
Browse files Browse the repository at this point in the history
* Removed `jest-enzyme` package

* Adding check for

* Added CommunityProfile page

* Added tests for CommunityProfile page

* Fixed formatting errors

* Format fix

* Merge branch 'develop' of https://github.com/git-init-priyanshu/talawa-admin-clone into priyanshu

* Fixed merge conflicts

* Format fix

* Fix typecheck error

* Added language support

* Lint error fix

* Integrated APIs

* Revert changes

* Fixed Failing Test

* FIxed failing  test

* Fixed LoginPage failing tests

* Full code coverage

* Redesigned the Donations page

* Added Tests

* Fixed formatting errors

* 100% code coverage for OrgListCard.tsx
  • Loading branch information
git-init-priyanshu authored Apr 7, 2024
1 parent c9da410 commit 1abea97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/OrgListCard/OrgListCard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import 'jest-location-mock';
import { I18nextProvider } from 'react-i18next';

Expand All @@ -19,6 +19,9 @@ const MOCKS = [
{
request: {
query: IS_SAMPLE_ORGANIZATION_QUERY,
variables: {
isSampleOrganizationId: 'xyz',
},
},
result: {
data: {
Expand All @@ -30,6 +33,14 @@ const MOCKS = [

const link = new StaticMockLink(MOCKS, true);

async function wait(ms = 100): Promise<void> {
await act(() => {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
});
}

const props: InterfaceOrgListCardProps = {
data: {
_id: 'xyz',
Expand Down Expand Up @@ -64,7 +75,7 @@ const props: InterfaceOrgListCardProps = {
};

describe('Testing the Super Dash List', () => {
test('should render props and text elements test for the page component', () => {
test('should render props and text elements test for the page component', async () => {
removeItem('id');
setItem('id', '123'); // Means the user is an admin

Expand All @@ -77,12 +88,15 @@ describe('Testing the Super Dash List', () => {
</BrowserRouter>
</MockedProvider>,
);
await wait();
expect(screen.getByAltText(/Dogs Care image/i)).toBeInTheDocument();
expect(screen.getByText(/Admins:/i)).toBeInTheDocument();
expect(screen.getByText(/Members:/i)).toBeInTheDocument();
expect(screen.getByText('Dogs Care')).toBeInTheDocument();
expect(screen.getByText(/Sample City/i)).toBeInTheDocument();
expect(screen.getByText(/123 Sample Street/i)).toBeInTheDocument();
expect(screen.getByTestId(/manageBtn/i)).toBeInTheDocument();
expect(screen.getByTestId(/flaskIcon/i)).toBeInTheDocument();
userEvent.click(screen.getByTestId(/manageBtn/i));
removeItem('id');
});
Expand Down
1 change: 1 addition & 0 deletions src/components/OrgListCard/OrgListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element {
width={12}
className={styles.flaskIcon}
title={t('sampleOrganization')}
data-testid="flaskIcon"
/>
)}
{' '}
Expand Down

0 comments on commit 1abea97

Please sign in to comment.