decidim-comments 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/comments/bundle.js +15 -15
- data/app/assets/javascripts/decidim/comments/bundle.js.map +1 -1
- data/app/commands/decidim/comments/create_comment.rb +2 -1
- data/app/forms/decidim/comments/comment_form.rb +1 -0
- data/app/frontend/application/apollo_client.js +1 -1
- data/app/frontend/application/application.component.jsx +1 -1
- data/app/frontend/comments/add_comment_form.component.jsx +76 -20
- data/app/frontend/comments/add_comment_form.component.test.jsx +77 -22
- data/app/frontend/comments/add_comment_form.fragment.graphql +6 -0
- data/app/frontend/comments/add_comment_form.mutation.graphql +2 -2
- data/app/frontend/comments/comment.component.jsx +15 -15
- data/app/frontend/comments/comment.component.test.jsx +42 -41
- data/app/frontend/comments/comment_order_selector.component.jsx +1 -1
- data/app/frontend/comments/comment_thread.component.jsx +7 -7
- data/app/frontend/comments/comment_thread.component.test.jsx +21 -19
- data/app/frontend/comments/comments.component.jsx +21 -17
- data/app/frontend/comments/comments.component.test.jsx +47 -32
- data/app/frontend/comments/comments.query.graphql +6 -3
- data/app/frontend/comments/down_vote_button.component.jsx +21 -10
- data/app/frontend/comments/up_vote_button.component.jsx +23 -12
- data/app/frontend/comments/vote_button.component.jsx +15 -7
- data/app/frontend/comments/vote_button_component.test.jsx +7 -2
- data/app/frontend/entry.js +1 -8
- data/app/frontend/support/generate_user_data.js +13 -0
- data/app/frontend/support/generate_user_group_data.js +14 -0
- data/app/helpers/decidim/comments/comments_helper.rb +10 -15
- data/app/models/decidim/comments/comment.rb +5 -7
- data/app/types/decidim/comments/comment_type.rb +5 -1
- data/config/locales/ca.yml +5 -1
- data/config/locales/en.yml +4 -1
- data/config/locales/es.yml +5 -1
- data/db/migrate/20170123102043_add_user_group_id_to_comments.rb +5 -0
- data/lib/decidim/comments/engine.rb +0 -1
- data/lib/decidim/comments/mutation_extensions.rb +2 -1
- metadata +10 -28
- data/app/frontend/support/generate_current_user_data.js +0 -13
- data/app/types/decidim/comments/author_type.rb +0 -15
@@ -1,5 +1,5 @@
|
|
1
|
-
mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int) {
|
2
|
-
addComment(commentableId: $commentableId, commentableType: $commentableType, body: $body, alignment: $alignment) {
|
1
|
+
mutation addComment($commentableId: String!, $commentableType: String!, $body: String!, $alignment: Int, $userGroupId: ID) {
|
2
|
+
addComment(commentableId: $commentableId, commentableType: $commentableType, body: $body, alignment: $alignment, userGroupId: $userGroupId) {
|
3
3
|
...CommentThread
|
4
4
|
}
|
5
5
|
}
|
@@ -68,12 +68,12 @@ class Comment extends Component {
|
|
68
68
|
* @returns {Void|DOMElement} - Render the reply button or not if user can reply
|
69
69
|
*/
|
70
70
|
_renderReplyButton() {
|
71
|
-
const { comment: { canHaveReplies },
|
71
|
+
const { comment: { canHaveReplies }, session } = this.props;
|
72
72
|
const { showReplyForm } = this.state;
|
73
73
|
|
74
|
-
if (
|
74
|
+
if (session && canHaveReplies) {
|
75
75
|
return (
|
76
|
-
<button
|
76
|
+
<button
|
77
77
|
className="comment__reply muted-link"
|
78
78
|
aria-controls="comment1-reply"
|
79
79
|
onClick={() => this.setState({ showReplyForm: !showReplyForm })}
|
@@ -92,10 +92,10 @@ class Comment extends Component {
|
|
92
92
|
* @returns {Void|DOMElement} - Render the reply button or not if user can reply
|
93
93
|
*/
|
94
94
|
_renderAdditionalReplyButton() {
|
95
|
-
const { comment: { canHaveReplies, hasReplies },
|
95
|
+
const { comment: { canHaveReplies, hasReplies }, session, isRootComment } = this.props;
|
96
96
|
const { showReplyForm } = this.state;
|
97
|
-
|
98
|
-
if (
|
97
|
+
|
98
|
+
if (session && canHaveReplies) {
|
99
99
|
if (hasReplies && isRootComment) {
|
100
100
|
|
101
101
|
return (
|
@@ -140,9 +140,9 @@ class Comment extends Component {
|
|
140
140
|
* @returns {Void|DomElement} - A wrapper element with comment replies inside
|
141
141
|
*/
|
142
142
|
_renderReplies() {
|
143
|
-
const { comment: { id, replies },
|
143
|
+
const { comment: { id, replies }, session, votable, articleClassName } = this.props;
|
144
144
|
let replyArticleClassName = 'comment comment--nested';
|
145
|
-
|
145
|
+
|
146
146
|
if (articleClassName === 'comment comment--nested') {
|
147
147
|
replyArticleClassName = `${replyArticleClassName} comment--nested--alt`;
|
148
148
|
}
|
@@ -155,7 +155,7 @@ class Comment extends Component {
|
|
155
155
|
<Comment
|
156
156
|
key={`comment_${id}_reply_${reply.id}`}
|
157
157
|
comment={reply}
|
158
|
-
|
158
|
+
session={session}
|
159
159
|
votable={votable}
|
160
160
|
articleClassName={replyArticleClassName}
|
161
161
|
/>
|
@@ -164,7 +164,7 @@ class Comment extends Component {
|
|
164
164
|
</div>
|
165
165
|
);
|
166
166
|
}
|
167
|
-
|
167
|
+
|
168
168
|
return null;
|
169
169
|
}
|
170
170
|
|
@@ -174,7 +174,7 @@ class Comment extends Component {
|
|
174
174
|
* @returns {Void|ReactElement} - Render the AddCommentForm component or not
|
175
175
|
*/
|
176
176
|
_renderReplyForm() {
|
177
|
-
const {
|
177
|
+
const { session, comment } = this.props;
|
178
178
|
const { showReplyForm } = this.state;
|
179
179
|
|
180
180
|
if (showReplyForm) {
|
@@ -182,7 +182,7 @@ class Comment extends Component {
|
|
182
182
|
<AddCommentForm
|
183
183
|
commentableId={comment.id}
|
184
184
|
commentableType="Decidim::Comments::Comment"
|
185
|
-
|
185
|
+
session={session}
|
186
186
|
showTitle={false}
|
187
187
|
submitButtonClassName="button small hollow"
|
188
188
|
onCommentAdded={() => this.setState({ showReplyForm: false })}
|
@@ -207,7 +207,7 @@ class Comment extends Component {
|
|
207
207
|
});
|
208
208
|
|
209
209
|
let label = '';
|
210
|
-
|
210
|
+
|
211
211
|
if (alignment === 1) {
|
212
212
|
label = I18n.t('components.comment.alignment.in_favor');
|
213
213
|
} else {
|
@@ -251,8 +251,8 @@ Comment.propTypes = {
|
|
251
251
|
propType(Comment.fragments.comment).isRequired,
|
252
252
|
propType(Comment.fragments.commentData).isRequired
|
253
253
|
]).isRequired,
|
254
|
-
|
255
|
-
|
254
|
+
session: PropTypes.shape({
|
255
|
+
user: PropTypes.any.isRequired
|
256
256
|
}),
|
257
257
|
articleClassName: PropTypes.string.isRequired,
|
258
258
|
isRootComment: PropTypes.bool,
|
@@ -1,25 +1,25 @@
|
|
1
1
|
/* eslint-disable no-unused-expressions */
|
2
|
-
import { shallow, mount }
|
3
|
-
import { filter }
|
4
|
-
import gql
|
2
|
+
import { shallow, mount } from 'enzyme';
|
3
|
+
import { filter } from 'graphql-anywhere';
|
4
|
+
import gql from 'graphql-tag';
|
5
5
|
|
6
|
-
import Comment
|
7
|
-
import AddCommentForm
|
8
|
-
import UpVoteButton
|
9
|
-
import DownVoteButton
|
6
|
+
import Comment from './comment.component';
|
7
|
+
import AddCommentForm from './add_comment_form.component';
|
8
|
+
import UpVoteButton from './up_vote_button.component';
|
9
|
+
import DownVoteButton from './down_vote_button.component';
|
10
10
|
|
11
|
-
import commentFragment
|
12
|
-
import commentDataFragment
|
13
|
-
import upVoteFragment
|
14
|
-
import downVoteFragment
|
11
|
+
import commentFragment from './comment.fragment.graphql';
|
12
|
+
import commentDataFragment from './comment_data.fragment.graphql';
|
13
|
+
import upVoteFragment from './up_vote.fragment.graphql';
|
14
|
+
import downVoteFragment from './down_vote.fragment.graphql';
|
15
15
|
|
16
|
-
import stubComponent
|
17
|
-
import generateCommentsData
|
18
|
-
import
|
16
|
+
import stubComponent from '../support/stub_component';
|
17
|
+
import generateCommentsData from '../support/generate_comments_data';
|
18
|
+
import generateUserData from '../support/generate_user_data';
|
19
19
|
|
20
20
|
describe("<Comment />", () => {
|
21
21
|
let comment = {};
|
22
|
-
let
|
22
|
+
let session = null;
|
23
23
|
|
24
24
|
stubComponent(AddCommentForm);
|
25
25
|
stubComponent(UpVoteButton);
|
@@ -28,8 +28,7 @@ describe("<Comment />", () => {
|
|
28
28
|
beforeEach(() => {
|
29
29
|
let commentsData = generateCommentsData(1);
|
30
30
|
commentsData[0].replies = generateCommentsData(3);
|
31
|
-
|
32
|
-
|
31
|
+
|
33
32
|
const fragment = gql`
|
34
33
|
${commentFragment}
|
35
34
|
${commentDataFragment}
|
@@ -38,44 +37,46 @@ describe("<Comment />", () => {
|
|
38
37
|
`;
|
39
38
|
|
40
39
|
comment = filter(fragment, commentsData[0]);
|
41
|
-
|
40
|
+
session = {
|
41
|
+
user: generateUserData()
|
42
|
+
}
|
42
43
|
});
|
43
44
|
|
44
45
|
it("should render an article with class comment", () => {
|
45
|
-
const wrapper = shallow(<Comment comment={comment}
|
46
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
46
47
|
expect(wrapper.find('article.comment')).to.present();
|
47
48
|
});
|
48
49
|
|
49
50
|
it("should render a time tag with comment's created at", () => {
|
50
|
-
const wrapper = shallow(<Comment comment={comment}
|
51
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
51
52
|
expect(wrapper.find('time')).to.have.text(comment.created_at);
|
52
53
|
});
|
53
54
|
|
54
55
|
it("should render author's name in a link with class author__name", () => {
|
55
|
-
const wrapper = shallow(<Comment comment={comment}
|
56
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
56
57
|
expect(wrapper.find('a.author__name')).to.have.text(comment.author.name);
|
57
58
|
});
|
58
59
|
|
59
60
|
it("should render author's avatar as a image tag", () => {
|
60
|
-
const wrapper = shallow(<Comment comment={comment}
|
61
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
61
62
|
expect(wrapper.find('a.author__avatar img')).to.have.attr('src').equal(comment.author.avatarUrl);
|
62
63
|
});
|
63
64
|
|
64
65
|
it("should render comment's body on a div with class comment__content", () => {
|
65
|
-
const wrapper = shallow(<Comment comment={comment}
|
66
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
66
67
|
expect(wrapper.find('div.comment__content')).to.have.text(comment.body);
|
67
68
|
});
|
68
69
|
|
69
70
|
it("should initialize with a state property showReplyForm as false", () => {
|
70
|
-
const wrapper = shallow(<Comment comment={comment}
|
71
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
71
72
|
expect(wrapper).to.have.state('showReplyForm', false);
|
72
73
|
});
|
73
74
|
|
74
75
|
it("should render a AddCommentForm component with the correct props when clicking the reply button", () => {
|
75
|
-
const wrapper = shallow(<Comment comment={comment}
|
76
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
76
77
|
expect(wrapper.find(AddCommentForm)).not.to.be.present();
|
77
78
|
wrapper.find('button.comment__reply').simulate('click');
|
78
|
-
expect(wrapper.find(AddCommentForm)).to.have.prop('
|
79
|
+
expect(wrapper.find(AddCommentForm)).to.have.prop('session').deep.equal(session);
|
79
80
|
expect(wrapper.find(AddCommentForm)).to.have.prop('commentableId').equal(comment.id);
|
80
81
|
expect(wrapper.find(AddCommentForm)).to.have.prop('commentableType').equal("Decidim::Comments::Comment");
|
81
82
|
expect(wrapper.find(AddCommentForm)).to.have.prop('showTitle').equal(false);
|
@@ -84,89 +85,89 @@ describe("<Comment />", () => {
|
|
84
85
|
|
85
86
|
it("should not render the reply button if the comment cannot have replies", () => {
|
86
87
|
comment.canHaveReplies = false;
|
87
|
-
const wrapper = shallow(<Comment comment={comment}
|
88
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
88
89
|
expect(wrapper.find('button.comment__reply')).not.to.be.present();
|
89
90
|
});
|
90
91
|
|
91
92
|
it("should not render the additional reply button if the parent comment has no replies and isRootcomment", () => {
|
92
93
|
comment.canHaveReplies = true;
|
93
94
|
comment.hasReplies = false;
|
94
|
-
const wrapper = shallow(<Comment comment={comment}
|
95
|
+
const wrapper = shallow(<Comment comment={comment} session={session} isRootComment />);
|
95
96
|
expect(wrapper.find('div.comment__additionalreply')).not.to.be.present();
|
96
97
|
});
|
97
98
|
|
98
99
|
it("should not render the additional reply button if the parent comment has replies and not isRootcomment", () => {
|
99
100
|
comment.canHaveReplies = true;
|
100
101
|
comment.hasReplies = true;
|
101
|
-
const wrapper = shallow(<Comment comment={comment}
|
102
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
102
103
|
expect(wrapper.find('div.comment__additionalreply')).not.to.be.present();
|
103
104
|
});
|
104
105
|
|
105
106
|
it("should render the additional reply button if the parent comment has replies and isRootcomment", () => {
|
106
107
|
comment.canHaveReplies = true;
|
107
108
|
comment.hasReplies = true;
|
108
|
-
const wrapper = shallow(<Comment comment={comment}
|
109
|
+
const wrapper = shallow(<Comment comment={comment} session={session} isRootComment />);
|
109
110
|
expect(wrapper.find('div.comment__additionalreply')).to.be.present();
|
110
111
|
});
|
111
112
|
|
112
113
|
it("should render comment replies a separate Comment components", () => {
|
113
|
-
const wrapper = shallow(<Comment comment={comment}
|
114
|
+
const wrapper = shallow(<Comment comment={comment} session={session} votable />);
|
114
115
|
wrapper.find(Comment).forEach((node, idx) => {
|
115
116
|
expect(node).to.have.prop("comment").deep.equal(comment.replies[idx]);
|
116
|
-
expect(node).to.have.prop("
|
117
|
+
expect(node).to.have.prop("session").deep.equal(session);
|
117
118
|
expect(node).to.have.prop("articleClassName").equal("comment comment--nested")
|
118
119
|
expect(node).to.have.prop("votable").equal(true);
|
119
120
|
});
|
120
121
|
});
|
121
122
|
|
122
123
|
it("should render comment replies with articleClassName as 'comment comment--nested comment--nested--alt' when articleClassName is 'comment comment--nested'", () => {
|
123
|
-
const wrapper = shallow(<Comment comment={comment}
|
124
|
+
const wrapper = shallow(<Comment comment={comment} session={session} articleClassName="comment comment--nested" />);
|
124
125
|
wrapper.find(Comment).forEach((node) => {
|
125
126
|
expect(node).to.have.prop("articleClassName").equal("comment comment--nested comment--nested--alt")
|
126
127
|
});
|
127
128
|
});
|
128
129
|
|
129
130
|
it("should have a default prop articleClassName with value 'comment'", () => {
|
130
|
-
const wrapper = mount(<Comment comment={comment}
|
131
|
+
const wrapper = mount(<Comment comment={comment} session={session} />);
|
131
132
|
expect(wrapper).to.have.prop("articleClassName").equal("comment");
|
132
133
|
});
|
133
134
|
|
134
135
|
it("should have a default prop isRootComment with value false", () => {
|
135
|
-
const wrapper = mount(<Comment comment={comment}
|
136
|
+
const wrapper = mount(<Comment comment={comment} session={session} />);
|
136
137
|
expect(wrapper).to.have.prop("isRootComment").equal(false);
|
137
138
|
});
|
138
139
|
|
139
140
|
describe("when user is not logged in", () => {
|
140
141
|
beforeEach(() => {
|
141
|
-
|
142
|
+
session = null;
|
142
143
|
});
|
143
144
|
|
144
145
|
it("should not render reply button", () => {
|
145
|
-
const wrapper = shallow(<Comment comment={comment}
|
146
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
146
147
|
expect(wrapper.find('button.comment__reply')).not.to.be.present();
|
147
148
|
});
|
148
149
|
});
|
149
150
|
|
150
151
|
it("should render a 'in favor' badge if comment's alignment is 1", () => {
|
151
152
|
comment.alignment = 1;
|
152
|
-
const wrapper = shallow(<Comment comment={comment}
|
153
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
153
154
|
expect(wrapper.find('span.success.label')).to.have.text('In favor');
|
154
155
|
});
|
155
156
|
|
156
157
|
it("should render a 'against' badge if comment's alignment is -1", () => {
|
157
158
|
comment.alignment = -1;
|
158
|
-
const wrapper = shallow(<Comment comment={comment}
|
159
|
+
const wrapper = shallow(<Comment comment={comment} session={session} />);
|
159
160
|
expect(wrapper.find('span.alert.label')).to.have.text('Against');
|
160
161
|
});
|
161
162
|
|
162
163
|
describe("when the comment is votable", () => {
|
163
164
|
it("should render an UpVoteButton component", () => {
|
164
|
-
const wrapper = shallow(<Comment comment={comment}
|
165
|
+
const wrapper = shallow(<Comment comment={comment} session={session} votable />);
|
165
166
|
expect(wrapper.find(UpVoteButton)).to.have.prop("comment").deep.equal(comment);
|
166
167
|
})
|
167
168
|
|
168
169
|
it("should render an DownVoteButton component", () => {
|
169
|
-
const wrapper = shallow(<Comment comment={comment}
|
170
|
+
const wrapper = shallow(<Comment comment={comment} session={session} votable />);
|
170
171
|
expect(wrapper.find(DownVoteButton)).to.have.prop("comment").deep.equal(comment);
|
171
172
|
})
|
172
173
|
});
|
@@ -28,7 +28,7 @@ class CommentOrderSelector extends Component {
|
|
28
28
|
<span className="order-by__text">{ I18n.t("components.comment_order_selector.title") }</span>
|
29
29
|
<ul className="dropdown menu" data-dropdown-menu>
|
30
30
|
<li>
|
31
|
-
<a>{ I18n.t(`components.comment_order_selector.${orderBy}`) }</a>
|
31
|
+
<a>{ I18n.t(`components.comment_order_selector.order.${orderBy}`) }</a>
|
32
32
|
<ul className="menu">
|
33
33
|
<li>
|
34
34
|
<a href="" className="test" onClick={(event) => this._updateOrder(event, "best_rated")} >
|
@@ -15,15 +15,15 @@ import commentThreadFragment from './comment_thread.fragment.graphql'
|
|
15
15
|
*/
|
16
16
|
class CommentThread extends Component {
|
17
17
|
render() {
|
18
|
-
const { comment,
|
18
|
+
const { comment, session, votable } = this.props;
|
19
19
|
|
20
20
|
return (
|
21
21
|
<div>
|
22
22
|
{this._renderTitle()}
|
23
23
|
<div className="comment-thread">
|
24
|
-
<Comment
|
25
|
-
comment={filter(Comment.fragments.comment, comment)}
|
26
|
-
|
24
|
+
<Comment
|
25
|
+
comment={filter(Comment.fragments.comment, comment)}
|
26
|
+
session={session}
|
27
27
|
votable={votable}
|
28
28
|
isRootComment
|
29
29
|
/>
|
@@ -39,7 +39,7 @@ class CommentThread extends Component {
|
|
39
39
|
*/
|
40
40
|
_renderTitle() {
|
41
41
|
const { comment: { author, hasReplies } } = this.props;
|
42
|
-
|
42
|
+
|
43
43
|
if (hasReplies) {
|
44
44
|
return (
|
45
45
|
<h6 className="comment-thread__title">
|
@@ -60,8 +60,8 @@ CommentThread.fragments = {
|
|
60
60
|
};
|
61
61
|
|
62
62
|
CommentThread.propTypes = {
|
63
|
-
|
64
|
-
|
63
|
+
session: PropTypes.shape({
|
64
|
+
user: PropTypes.any.isRequired
|
65
65
|
}),
|
66
66
|
comment: propType(CommentThread.fragments.comment).isRequired,
|
67
67
|
votable: PropTypes.bool
|
@@ -2,18 +2,18 @@ import { shallow } from 'enzyme';
|
|
2
2
|
import { filter } from 'graphql-anywhere';
|
3
3
|
import gql from 'graphql-tag';
|
4
4
|
|
5
|
-
import CommentThread
|
6
|
-
import Comment
|
5
|
+
import CommentThread from './comment_thread.component';
|
6
|
+
import Comment from './comment.component';
|
7
7
|
|
8
|
-
import commentThreadFragment
|
8
|
+
import commentThreadFragment from './comment_thread.fragment.graphql'
|
9
9
|
|
10
|
-
import stubComponent
|
11
|
-
import generateCommentsData
|
12
|
-
import
|
10
|
+
import stubComponent from '../support/stub_component';
|
11
|
+
import generateCommentsData from '../support/generate_comments_data';
|
12
|
+
import generateCUserData from '../support/generate_user_data';
|
13
13
|
|
14
14
|
describe('<CommentThread />', () => {
|
15
15
|
let comment = {};
|
16
|
-
let
|
16
|
+
let session = null;
|
17
17
|
|
18
18
|
const commentFragment = gql`
|
19
19
|
fragment Comment on Comment {
|
@@ -29,19 +29,21 @@ describe('<CommentThread />', () => {
|
|
29
29
|
|
30
30
|
beforeEach(() => {
|
31
31
|
const commentsData = generateCommentsData(1);
|
32
|
-
|
32
|
+
|
33
33
|
const fragment = gql`
|
34
34
|
${commentThreadFragment}
|
35
35
|
${commentFragment}
|
36
36
|
`;
|
37
37
|
|
38
|
-
|
38
|
+
session = {
|
39
|
+
user: generateCUserData()
|
40
|
+
};
|
39
41
|
comment = filter(fragment, commentsData[0]);
|
40
42
|
});
|
41
43
|
|
42
44
|
describe("when comment doesn't have replies", () => {
|
43
45
|
it("should not render a title with author name", () => {
|
44
|
-
const wrapper = shallow(<CommentThread comment={comment}
|
46
|
+
const wrapper = shallow(<CommentThread comment={comment} session={session} />);
|
45
47
|
expect(wrapper.find('h6.comment-thread__title')).not.to.present();
|
46
48
|
});
|
47
49
|
});
|
@@ -52,30 +54,30 @@ describe('<CommentThread />', () => {
|
|
52
54
|
});
|
53
55
|
|
54
56
|
it("should render a h6 comment-thread__title with author name", () => {
|
55
|
-
const wrapper = shallow(<CommentThread comment={comment}
|
57
|
+
const wrapper = shallow(<CommentThread comment={comment} session={session} />);
|
56
58
|
expect(wrapper.find('h6.comment-thread__title')).to.have.text(`Conversation with ${comment.author.name}`);
|
57
59
|
});
|
58
60
|
});
|
59
61
|
|
60
62
|
describe("should render a Comment", () => {
|
61
|
-
it("and pass the
|
62
|
-
const wrapper = shallow(<CommentThread comment={comment}
|
63
|
-
expect(wrapper.find(Comment).first()).to.have.prop("
|
63
|
+
it("and pass the session as a prop to it", () => {
|
64
|
+
const wrapper = shallow(<CommentThread comment={comment} session={session} />);
|
65
|
+
expect(wrapper.find(Comment).first()).to.have.prop("session").deep.equal(session);
|
64
66
|
});
|
65
67
|
|
66
68
|
it("and pass filter comment data as a prop to it", () => {
|
67
|
-
const wrapper = shallow(<CommentThread comment={comment}
|
69
|
+
const wrapper = shallow(<CommentThread comment={comment} session={session} />);
|
68
70
|
expect(wrapper.find(Comment).first()).to.have.prop("comment").deep.equal(filter(commentFragment, comment));
|
69
71
|
});
|
70
72
|
|
71
73
|
it("and pass the votable as a prop to it", () => {
|
72
|
-
const wrapper = shallow(<CommentThread comment={comment}
|
74
|
+
const wrapper = shallow(<CommentThread comment={comment} session={session} votable />);
|
73
75
|
expect(wrapper.find(Comment).first()).to.have.prop("votable").equal(true);
|
74
76
|
});
|
75
|
-
|
77
|
+
|
76
78
|
it("and pass the isRootComment equal true", () => {
|
77
|
-
const wrapper = shallow(<CommentThread comment={comment}
|
79
|
+
const wrapper = shallow(<CommentThread comment={comment} session={session} votable isRootComment />);
|
78
80
|
expect(wrapper.find(Comment).first()).to.have.prop("isRootComment").equal(true);
|
79
81
|
});
|
80
|
-
});
|
82
|
+
});
|
81
83
|
});
|