Skip to content

Commit

Permalink
100% code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
git-init-priyanshu committed May 9, 2024
1 parent 16c8c9e commit 4e30282
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src/components/UserPortal/PostCard/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ interface InterfaceCommentCardProps {
handleDislikeComment: (commentId: string) => void;
}

interface InterfacePostCardProps extends InterfacePostCard {
fetchPosts: () => void;
}

export default function postCard(props: InterfacePostCardProps): JSX.Element {
export default function postCard(props: InterfacePostCard): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'postCard',
});
Expand Down
9 changes: 9 additions & 0 deletions src/screens/UserPortal/Posts/Posts.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ describe('Testing Home Screen: User Portal', () => {
expect(screen.queryByText('post two')).toBeInTheDocument();
expect(screen.queryByText('This is the post two')).toBeInTheDocument();
});

test('Checking if refetch works after deleting this post', async () => {
setItem('userId', '640d98d9eb6a743d75341067');
renderHomeScreen();
await wait();

userEvent.click(screen.getAllByTestId('dropdown')[1]);
userEvent.click(screen.getByTestId('deletePost'));
});
});

describe('HomeScreen with invalid orgId', () => {
Expand Down
17 changes: 3 additions & 14 deletions src/screens/UserPortal/Posts/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export default function home(): JSX.Element {
commentCount,
comments: postComments,
likedBy: allLikes,
fetchPosts: () => refetch(),
};

return cardProps;
Expand Down Expand Up @@ -324,13 +325,7 @@ export default function home(): JSX.Element {
<div className={` ${styles.pinnedPostsCardsContainer}`}>
{pinnedPosts.map(({ node }: { node: InterfacePostNode }) => {
const cardProps = getCardProps(node);
return (
<PostCard
key={node._id}
{...cardProps}
fetchPosts={() => refetch()}
/>
);
return <PostCard key={node._id} {...cardProps} />;
})}
</div>
</div>
Expand Down Expand Up @@ -362,13 +357,7 @@ export default function home(): JSX.Element {
<Row className="my-2">
{posts.map(({ node }: { node: InterfacePostNode }) => {
const cardProps = getCardProps(node);
return (
<PostCard
key={node._id}
{...cardProps}
fetchPosts={() => refetch()}
/>
);
return <PostCard key={node._id} {...cardProps} />;
})}
</Row>
) : (
Expand Down
1 change: 1 addition & 0 deletions src/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ export interface InterfacePostCard {
lastName: string;
id: string;
}[];
fetchPosts: () => void;
}
export interface InterfaceCreateCampaign {
campaignName: string;
Expand Down

0 comments on commit 4e30282

Please sign in to comment.