Skip to content

Commit ece6cb7

Browse files
committed
Fix crashing test
1 parent 0760fd4 commit ece6cb7

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/components/post/__tests__/PostCommentList.test.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import * as React from 'react';
22
import { render } from '@testing-library/react';
33
import PostCommentsList, { PostCommentsListProps } from '../PostCommentsList';
4+
import { Comment } from '../../../lib/graphql/post';
5+
import { MemoryRouter } from 'react-router-dom';
46

57
describe('PostCommentsList', () => {
6-
const sampleComments = [
8+
const sampleComments: Comment[] = [
79
{
810
id: 'a38d0552-d2a4-4079-96ca-09aef72f00e1',
911
user: {
1012
id: '0bcdf3e5-a228-42c3-8b52-3f0dc118dfd8',
1113
username: 'blablabla',
1214
profile: {
15+
id: '',
1316
thumbnail: null,
1417
},
1518
},
@@ -25,6 +28,7 @@ describe('PostCommentsList', () => {
2528
id: '0bcdf3e5-a228-42c3-8b52-3f0dc118dfd8',
2629
username: 'blablabla',
2730
profile: {
31+
id: '',
2832
thumbnail: null,
2933
},
3034
},
@@ -40,6 +44,7 @@ describe('PostCommentsList', () => {
4044
id: '0bcdf3e5-a228-42c3-8b52-3f0dc118dfd8',
4145
username: 'blablabla',
4246
profile: {
47+
id: '',
4348
thumbnail: null,
4449
},
4550
},
@@ -56,7 +61,11 @@ describe('PostCommentsList', () => {
5661
currentUserId: null,
5762
onRemove: () => {},
5863
};
59-
const utils = render(<PostCommentsList {...initialProps} {...props} />);
64+
const utils = render(
65+
<MemoryRouter>
66+
<PostCommentsList {...initialProps} {...props} />
67+
</MemoryRouter>,
68+
);
6069
return {
6170
...utils,
6271
};

src/components/post/__tests__/PostReplies.test.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,43 @@ import * as React from 'react';
22
import { render, fireEvent } from '@testing-library/react';
33
import PostReplies, { PostRepliesProps } from '../PostReplies';
44
import renderWithRedux from '../../../lib/renderWithRedux';
5+
import { Comment } from '../../../lib/graphql/post';
6+
import { MemoryRouter } from 'react-router-dom';
57

6-
const sampleComments = [
8+
const sampleComments: Comment[] = [
79
{
810
id: '67139c27-cf3c-4da6-a25c-4b0ec54be379',
911
user: {
1012
id: '0bcdf3e5-a228-42c3-8b52-3f0dc118dfd8',
1113
username: 'blablabla',
1214
profile: {
15+
id: '67139c27-cf3c-4da6-a25c-4b0ec54be379',
1316
thumbnail: null,
1417
},
1518
},
1619
text: '첫번째 댓글',
1720
replies_count: 2,
1821
created_at: '2019-06-19T14:56:26.022Z',
22+
deleted: false,
23+
level: 0,
24+
replies: undefined,
1925
},
2026
{
2127
id: '2f86fc23-2128-4e7c-99f5-f0fc4553afc8',
2228
user: {
2329
id: '0bcdf3e5-a228-42c3-8b52-3f0dc118dfd8',
2430
username: 'blablabla',
2531
profile: {
32+
id: '67139c27-cf3c-4da6-a25c-4b0ec54be379',
2633
thumbnail: null,
2734
},
2835
},
2936
text: '두번째 댓글',
3037
replies_count: 0,
3138
created_at: '2019-06-19T15:08:08.085Z',
39+
deleted: false,
40+
level: 0,
41+
replies: undefined,
3242
},
3343
];
3444
describe('PostReplies', () => {
@@ -37,8 +47,13 @@ describe('PostReplies', () => {
3747
comments: sampleComments,
3848
onReply: () => {},
3949
onHide: () => {},
50+
onRemove: () => {},
4051
};
41-
const utils = renderWithRedux(<PostReplies {...initialProps} {...props} />);
52+
const utils = renderWithRedux(
53+
<MemoryRouter>
54+
<PostReplies {...initialProps} {...props} />
55+
</MemoryRouter>,
56+
);
4257
return {
4358
...utils,
4459
};

0 commit comments

Comments
 (0)