Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
aashimawadhwa committed Oct 5, 2023
1 parent 590552e commit bb05601
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
18 changes: 12 additions & 6 deletions src/components/OrgPostCard/OrgPostCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
waitFor,
} from '@testing-library/react';
import { MockedProvider } from '@apollo/react-testing';
import OrgPostCard from './OrgPostCard';
import { I18nextProvider } from 'react-i18next';
import userEvent from '@testing-library/user-event';
import OrgPostCard from './OrgPostCard';
import 'jest-localstorage-mock';
import {
DELETE_POST_MUTATION,
Expand All @@ -19,6 +19,7 @@ import {
import i18nForTest from 'utils/i18nForTest';
import { StaticMockLink } from 'utils/StaticMockLink';
import convertToBase64 from 'utils/convertToBase64';
import { BrowserRouter } from 'react-router-dom';
const MOCKS = [
{
request: {
Expand All @@ -28,7 +29,7 @@ const MOCKS = [
result: {
data: {
removePost: {
_id: '1',
_id: '123',
},
},
},
Expand Down Expand Up @@ -99,7 +100,10 @@ describe('Testing Organization Post Card', () => {
error: jest.fn(),
},
}));

jest.mock('react', () => ({
...jest.requireActual('react'),
useRef: jest.fn(),
}));
global.alert = jest.fn();

test('renders with default props', () => {
Expand Down Expand Up @@ -201,9 +205,11 @@ describe('Testing Organization Post Card', () => {
test('Testing post delete functionality', async () => {
render(
<MockedProvider addTypename={false} link={link}>
<I18nextProvider i18n={i18nForTest}>
<OrgPostCard {...props} />
</I18nextProvider>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<OrgPostCard {...props} />
</I18nextProvider>
</BrowserRouter>
</MockedProvider>
);

Expand Down
8 changes: 5 additions & 3 deletions src/components/OrgPostCard/OrgPostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ interface InterfaceOrgPostCardProps {
pinned: boolean;
}

function orgPostCard(props: InterfaceOrgPostCardProps): JSX.Element {
// eslint-disable-next-line @typescript-eslint/naming-convention
export default function OrgPostCard(
props: InterfaceOrgPostCardProps
): JSX.Element {
const [postformState, setPostFormState] = useState({
posttitle: '',
postinfo: '',
Expand Down Expand Up @@ -241,6 +244,7 @@ function orgPostCard(props: InterfaceOrgPostCardProps): JSX.Element {
{props.postVideo && (
<Card
className={styles.card}
data-testid="cardVid"
onMouseEnter={handleVideoPlay}
onMouseLeave={handleVideoPause}
>
Expand Down Expand Up @@ -623,5 +627,3 @@ function orgPostCard(props: InterfaceOrgPostCardProps): JSX.Element {
</>
);
}

export default orgPostCard;
1 change: 0 additions & 1 deletion src/screens/OrgPost/OrgPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ function orgPost(): JSX.Element {
if (a.pinned) {
return -1;
}

return 1;
});
return (
Expand Down

0 comments on commit bb05601

Please sign in to comment.