decidim-comments 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
@@ -24,8 +24,8 @@ export class Comments extends Component {
|
|
24
24
|
const { comments, reorderComments, orderBy, loading } = this.props;
|
25
25
|
let commentClasses = "comments";
|
26
26
|
let commentHeader = I18n.t("components.comments.title", { count: comments.length });
|
27
|
-
|
28
|
-
if (loading) {
|
27
|
+
|
28
|
+
if (loading) {
|
29
29
|
commentClasses += " loading-comments"
|
30
30
|
commentHeader = I18n.t("components.comments.loading");
|
31
31
|
}
|
@@ -37,7 +37,7 @@ export class Comments extends Component {
|
|
37
37
|
<h2 className="order-by__text section-heading">
|
38
38
|
{ commentHeader }
|
39
39
|
</h2>
|
40
|
-
<CommentOrderSelector
|
40
|
+
<CommentOrderSelector
|
41
41
|
reorderComments={reorderComments}
|
42
42
|
defaultOrderBy={orderBy}
|
43
43
|
/>
|
@@ -55,13 +55,13 @@ export class Comments extends Component {
|
|
55
55
|
* @returns {ReactComponent[]} - A collection of CommentThread components
|
56
56
|
*/
|
57
57
|
_renderCommentThreads() {
|
58
|
-
const { comments,
|
58
|
+
const { comments, session, options: { votable } } = this.props;
|
59
59
|
|
60
60
|
return comments.map((comment) => (
|
61
|
-
<CommentThread
|
62
|
-
key={comment.id}
|
63
|
-
comment={filter(CommentThread.fragments.comment, comment)}
|
64
|
-
|
61
|
+
<CommentThread
|
62
|
+
key={comment.id}
|
63
|
+
comment={filter(CommentThread.fragments.comment, comment)}
|
64
|
+
session={session}
|
65
65
|
votable={votable}
|
66
66
|
/>
|
67
67
|
))
|
@@ -73,12 +73,12 @@ export class Comments extends Component {
|
|
73
73
|
* @returns {Void|ReactComponent} - A AddCommentForm component or nothing
|
74
74
|
*/
|
75
75
|
_renderAddCommentForm() {
|
76
|
-
const {
|
76
|
+
const { session, commentableId, commentableType, options: { arguable } } = this.props;
|
77
77
|
|
78
|
-
if (
|
78
|
+
if (session) {
|
79
79
|
return (
|
80
|
-
<AddCommentForm
|
81
|
-
|
80
|
+
<AddCommentForm
|
81
|
+
session={session}
|
82
82
|
commentableId={commentableId}
|
83
83
|
commentableType={commentableType}
|
84
84
|
arguable={arguable}
|
@@ -95,8 +95,8 @@ Comments.propTypes = {
|
|
95
95
|
comments: PropTypes.arrayOf(PropTypes.shape({
|
96
96
|
id: PropTypes.string.isRequired
|
97
97
|
})),
|
98
|
-
|
99
|
-
|
98
|
+
session: PropTypes.shape({
|
99
|
+
user: PropTypes.any.isRequired
|
100
100
|
}),
|
101
101
|
commentableId: PropTypes.string.isRequired,
|
102
102
|
commentableType: PropTypes.string.isRequired,
|
@@ -111,17 +111,21 @@ Comments.propTypes = {
|
|
111
111
|
* Wrap the Comments component with a GraphQL query and children
|
112
112
|
* fragments.
|
113
113
|
*/
|
114
|
+
|
115
|
+
window.Comments = Comments;
|
116
|
+
|
114
117
|
const CommentsWithData = graphql(gql`
|
115
118
|
${commentsQuery}
|
119
|
+
${AddCommentForm.fragments.user}
|
116
120
|
${CommentThread.fragments.comment}
|
117
121
|
`, {
|
118
122
|
options: {
|
119
123
|
pollInterval: 15000
|
120
124
|
},
|
121
|
-
props: ({ ownProps, data: {loading,
|
125
|
+
props: ({ ownProps, data: { loading, session, comments, refetch }}) => ({
|
122
126
|
loading: loading,
|
123
127
|
comments: comments || [],
|
124
|
-
|
128
|
+
session,
|
125
129
|
commentableId: ownProps.commentableId,
|
126
130
|
commentableType: ownProps.commentableType,
|
127
131
|
orderBy: ownProps.orderBy,
|
@@ -141,7 +145,7 @@ const CommentsWithData = graphql(gql`
|
|
141
145
|
*/
|
142
146
|
const CommentsApplication = ({ locale, commentableId, commentableType, options }) => (
|
143
147
|
<Application locale={locale}>
|
144
|
-
<CommentsWithData
|
148
|
+
<CommentsWithData
|
145
149
|
commentableId={commentableId}
|
146
150
|
commentableType={commentableType}
|
147
151
|
options={options}
|
@@ -1,22 +1,22 @@
|
|
1
|
-
import { shallow }
|
2
|
-
import { filter }
|
3
|
-
import gql
|
1
|
+
import { shallow } from 'enzyme';
|
2
|
+
import { filter } from 'graphql-anywhere';
|
3
|
+
import gql from 'graphql-tag';
|
4
4
|
|
5
|
-
import { Comments }
|
6
|
-
import CommentThread
|
7
|
-
import AddCommentForm
|
8
|
-
import CommentOrderSelector
|
5
|
+
import { Comments } from './comments.component';
|
6
|
+
import CommentThread from './comment_thread.component';
|
7
|
+
import AddCommentForm from './add_comment_form.component';
|
8
|
+
import CommentOrderSelector from './comment_order_selector.component';
|
9
9
|
|
10
|
-
import commentsQuery
|
10
|
+
import commentsQuery from './comments.query.graphql'
|
11
11
|
|
12
|
-
import stubComponent
|
13
|
-
import generateCommentsData
|
14
|
-
import
|
15
|
-
import resolveGraphQLQuery
|
12
|
+
import stubComponent from '../support/stub_component';
|
13
|
+
import generateCommentsData from '../support/generate_comments_data';
|
14
|
+
import generateUserData from '../support/generate_user_data';
|
15
|
+
import resolveGraphQLQuery from '../support/resolve_graphql_query';
|
16
16
|
|
17
17
|
describe('<Comments />', () => {
|
18
18
|
let comments = [];
|
19
|
-
let
|
19
|
+
let session = null;
|
20
20
|
const commentableId = "1";
|
21
21
|
const commentableType = "Decidim::ParticipatoryProcess";
|
22
22
|
const orderBy = "older";
|
@@ -28,6 +28,14 @@ describe('<Comments />', () => {
|
|
28
28
|
}
|
29
29
|
`;
|
30
30
|
|
31
|
+
const addCommentFragment = gql`
|
32
|
+
fragment AddCommentForm on User {
|
33
|
+
verifiedUserGroups {
|
34
|
+
id
|
35
|
+
}
|
36
|
+
}
|
37
|
+
`;
|
38
|
+
|
31
39
|
stubComponent(CommentOrderSelector)
|
32
40
|
|
33
41
|
stubComponent(CommentThread, {
|
@@ -36,21 +44,28 @@ describe('<Comments />', () => {
|
|
36
44
|
}
|
37
45
|
});
|
38
46
|
|
39
|
-
stubComponent(AddCommentForm
|
47
|
+
stubComponent(AddCommentForm, {
|
48
|
+
fragments: {
|
49
|
+
user: addCommentFragment
|
50
|
+
}
|
51
|
+
});
|
40
52
|
|
41
53
|
beforeEach(() => {
|
42
|
-
const
|
54
|
+
const userData = generateUserData();
|
43
55
|
const commentsData = generateCommentsData(15);
|
44
56
|
|
45
57
|
const query = gql`
|
46
58
|
${commentsQuery}
|
47
59
|
${commentThreadFragment}
|
60
|
+
${addCommentFragment}
|
48
61
|
`;
|
49
62
|
|
50
63
|
const result = resolveGraphQLQuery(query, {
|
51
64
|
filterResult: false,
|
52
65
|
rootValue: {
|
53
|
-
|
66
|
+
session: {
|
67
|
+
user: userData
|
68
|
+
},
|
54
69
|
comments: commentsData
|
55
70
|
},
|
56
71
|
variables: {
|
@@ -60,40 +75,40 @@ describe('<Comments />', () => {
|
|
60
75
|
}
|
61
76
|
});
|
62
77
|
|
63
|
-
|
78
|
+
session = result.session;
|
64
79
|
comments = result.comments;
|
65
80
|
});
|
66
81
|
|
67
82
|
it("should render loading-comments calss and the respective loading text", () => {
|
68
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
83
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} loading />);
|
69
84
|
expect(wrapper.find('.loading-comments')).to.be.present();
|
70
85
|
expect(wrapper.find('h2')).to.have.text("Loading comments ...");
|
71
86
|
});
|
72
87
|
|
73
88
|
it("should render a div of id comments", () => {
|
74
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
89
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
75
90
|
expect(wrapper.find('#comments')).to.be.present();
|
76
91
|
});
|
77
92
|
|
78
93
|
describe("should render a CommentThread component for each comment", () => {
|
79
94
|
it("and pass filter comment data as a prop to it", () => {
|
80
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
95
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
81
96
|
expect(wrapper).to.have.exactly(comments.length).descendants(CommentThread);
|
82
97
|
wrapper.find(CommentThread).forEach((node, idx) => {
|
83
98
|
expect(node).to.have.prop("comment").deep.equal(filter(commentThreadFragment, comments[idx]));
|
84
99
|
});
|
85
100
|
});
|
86
101
|
|
87
|
-
it("and pass the
|
88
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
102
|
+
it("and pass the session as a prop to it", () => {
|
103
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
89
104
|
expect(wrapper).to.have.exactly(comments.length).descendants(CommentThread);
|
90
105
|
wrapper.find(CommentThread).forEach((node) => {
|
91
|
-
expect(node).to.have.prop("
|
106
|
+
expect(node).to.have.prop("session").deep.equal(session);
|
92
107
|
});
|
93
108
|
});
|
94
109
|
|
95
110
|
it("and pass the option votable as a prop to it", () => {
|
96
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
111
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{ votable: true }} reorderComments={reorderComments} orderBy={orderBy} />);
|
97
112
|
expect(wrapper).to.have.exactly(comments.length).descendants(CommentThread);
|
98
113
|
wrapper.find(CommentThread).forEach((node) => {
|
99
114
|
expect(node).to.have.prop("votable").equal(true);
|
@@ -102,41 +117,41 @@ describe('<Comments />', () => {
|
|
102
117
|
});
|
103
118
|
|
104
119
|
it("should render comments count", () => {
|
105
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
120
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
106
121
|
const rex = new RegExp(`${comments.length} comments`);
|
107
122
|
expect(wrapper.find('h2.section-heading')).to.have.text().match(rex);
|
108
123
|
});
|
109
124
|
|
110
125
|
it("should render a AddCommentForm component and pass 'options.arguable' as a prop", () => {
|
111
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
126
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{ arguable: true }} reorderComments={reorderComments} orderBy={orderBy} />);
|
112
127
|
expect(wrapper).to.have.exactly(1).descendants(AddCommentForm);
|
113
128
|
expect(wrapper.find(AddCommentForm)).to.have.prop('arguable').equal(true);
|
114
129
|
});
|
115
130
|
|
116
|
-
describe("if
|
131
|
+
describe("if session is not present", () => {
|
117
132
|
beforeEach(() => {
|
118
|
-
|
133
|
+
session = null;
|
119
134
|
});
|
120
135
|
|
121
136
|
it("should not render a AddCommentForm component", () => {
|
122
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
137
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
123
138
|
expect(wrapper.find(AddCommentForm)).not.to.be.present();
|
124
139
|
});
|
125
140
|
});
|
126
141
|
|
127
142
|
describe("should render a CommentOrderSelector component", () => {
|
128
143
|
it("should render a CommentOrderSelector component", () => {
|
129
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
144
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
130
145
|
expect(wrapper.find(CommentOrderSelector)).to.be.present();
|
131
146
|
});
|
132
147
|
|
133
148
|
it("and pass the reorderComments as a prop to it", () => {
|
134
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
149
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
135
150
|
expect(wrapper.find(CommentOrderSelector)).to.have.prop('reorderComments').deep.equal(reorderComments);
|
136
151
|
});
|
137
152
|
|
138
153
|
it("and pass the orderBy as a prop to it", () => {
|
139
|
-
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType}
|
154
|
+
const wrapper = shallow(<Comments comments={comments} commentableId={commentableId} commentableType={commentableType} session={session} options={{}} reorderComments={reorderComments} orderBy={orderBy} />);
|
140
155
|
expect(wrapper.find(CommentOrderSelector)).to.have.prop('defaultOrderBy').equal('older');
|
141
156
|
});
|
142
157
|
});
|
@@ -1,7 +1,10 @@
|
|
1
1
|
query GetComments($commentableId: String!, $commentableType: String!, $orderBy: String) {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
session {
|
3
|
+
user {
|
4
|
+
name
|
5
|
+
avatarUrl
|
6
|
+
}
|
7
|
+
...AddCommentForm
|
5
8
|
}
|
6
9
|
comments(commentableId: $commentableId, commentableType: $commentableType, orderBy: $orderBy) {
|
7
10
|
id
|
@@ -12,15 +12,26 @@ import commentDataFragment from './comment_data.fragment.graphql';
|
|
12
12
|
import upVoteFragment from './up_vote.fragment.graphql';
|
13
13
|
import downVoteFragment from './down_vote.fragment.graphql';
|
14
14
|
|
15
|
-
export const DownVoteButton = ({ comment: { downVotes, upVoted, downVoted }, downVote }) =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
export const DownVoteButton = ({ comment: { downVotes, upVoted, downVoted }, downVote }) => {
|
16
|
+
let selectedClass = '';
|
17
|
+
|
18
|
+
if (downVoted) {
|
19
|
+
selectedClass = 'is-vote-selected';
|
20
|
+
} else if (upVoted) {
|
21
|
+
selectedClass = 'is-vote-notselected';
|
22
|
+
}
|
23
|
+
|
24
|
+
return (
|
25
|
+
<VoteButton
|
26
|
+
buttonClassName="comment__votes--down"
|
27
|
+
iconName="icon-chevron-bottom"
|
28
|
+
votes={downVotes}
|
29
|
+
voteAction={downVote}
|
30
|
+
disabled={upVoted || downVoted}
|
31
|
+
selectedClass={selectedClass}
|
32
|
+
/>
|
33
|
+
);
|
34
|
+
};
|
24
35
|
|
25
36
|
DownVoteButton.fragments = {
|
26
37
|
comment: gql`
|
@@ -35,7 +46,7 @@ DownVoteButton.propTypes = {
|
|
35
46
|
|
36
47
|
const DownVoteButtonWithMutation = graphql(gql`
|
37
48
|
${downVoteMutation}
|
38
|
-
${commentFragment}
|
49
|
+
${commentFragment}
|
39
50
|
${commentDataFragment}
|
40
51
|
${upVoteFragment}
|
41
52
|
${downVoteFragment}
|
@@ -12,15 +12,26 @@ import commentDataFragment from './comment_data.fragment.graphql';
|
|
12
12
|
import upVoteFragment from './up_vote.fragment.graphql';
|
13
13
|
import downVoteFragment from './down_vote.fragment.graphql';
|
14
14
|
|
15
|
-
export const UpVoteButton = ({ comment: { upVotes, upVoted, downVoted }, upVote }) =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
export const UpVoteButton = ({ comment: { upVotes, upVoted, downVoted }, upVote }) => {
|
16
|
+
let selectedClass = '';
|
17
|
+
|
18
|
+
if (upVoted) {
|
19
|
+
selectedClass = 'is-vote-selected';
|
20
|
+
} else if (downVoted) {
|
21
|
+
selectedClass = 'is-vote-notselected';
|
22
|
+
}
|
23
|
+
|
24
|
+
return (
|
25
|
+
<VoteButton
|
26
|
+
buttonClassName="comment__votes--up"
|
27
|
+
iconName="icon-chevron-top"
|
28
|
+
votes={upVotes}
|
29
|
+
voteAction={upVote}
|
30
|
+
disabled={upVoted || downVoted}
|
31
|
+
selectedClass={selectedClass}
|
32
|
+
/>
|
33
|
+
);
|
34
|
+
}
|
24
35
|
|
25
36
|
UpVoteButton.fragments = {
|
26
37
|
comment: gql`
|
@@ -58,10 +69,10 @@ const UpVoteButtonWithMutation = graphql(gql`
|
|
58
69
|
}
|
59
70
|
},
|
60
71
|
updateQueries: {
|
61
|
-
GetComments: (prev, { mutationResult: { data } }) => {
|
72
|
+
GetComments: (prev, { mutationResult: { data } }) => {
|
62
73
|
const commentReducer = (comment) => {
|
63
74
|
const replies = comment.replies || [];
|
64
|
-
|
75
|
+
|
65
76
|
if (comment.id === ownProps.comment.id) {
|
66
77
|
return data.comment.upVote;
|
67
78
|
}
|
@@ -78,7 +89,7 @@ const UpVoteButtonWithMutation = graphql(gql`
|
|
78
89
|
}
|
79
90
|
}
|
80
91
|
})
|
81
|
-
})
|
92
|
+
})
|
82
93
|
})(UpVoteButton);
|
83
94
|
|
84
95
|
export default UpVoteButtonWithMutation;
|
@@ -1,18 +1,26 @@
|
|
1
|
-
import { PropTypes } from 'react';
|
1
|
+
import { Component, PropTypes } from 'react';
|
2
2
|
import Icon from '../application/icon.component';
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
class VoteButton extends Component {
|
5
|
+
render() {
|
6
|
+
const { buttonClassName, iconName, votes, voteAction, disabled, selectedClass } = this.props;
|
7
|
+
let voteClasses = `${buttonClassName} ${selectedClass}`;
|
8
|
+
|
9
|
+
return (
|
10
|
+
<button className={voteClasses} onClick={() => voteAction()} disabled={disabled}>
|
11
|
+
<Icon name={iconName} iconExtraClassName="icon--small" />
|
12
|
+
{ ` ${votes}` }
|
13
|
+
</button>
|
14
|
+
);
|
15
|
+
}
|
16
|
+
}
|
10
17
|
|
11
18
|
VoteButton.propTypes = {
|
12
19
|
buttonClassName: PropTypes.string.isRequired,
|
13
20
|
iconName: PropTypes.string.isRequired,
|
14
21
|
votes: PropTypes.number.isRequired,
|
15
22
|
voteAction: PropTypes.func.isRequired,
|
23
|
+
selectedClass: PropTypes.string,
|
16
24
|
disabled: PropTypes.bool
|
17
25
|
};
|
18
26
|
|
@@ -21,7 +21,7 @@ describe("<VoteButton />", () => {
|
|
21
21
|
});
|
22
22
|
|
23
23
|
it("should render a Icon component with the correct name prop", () => {
|
24
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
|
24
|
+
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} />);
|
25
25
|
expect(wrapper.find(Icon)).to.have.prop("name").equal('vote-icon');
|
26
26
|
});
|
27
27
|
|
@@ -32,7 +32,12 @@ describe("<VoteButton />", () => {
|
|
32
32
|
});
|
33
33
|
|
34
34
|
it("should disable the button based on the disabled prop", () => {
|
35
|
-
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled />);
|
35
|
+
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled />);
|
36
36
|
expect(wrapper.find('button')).to.be.disabled();
|
37
37
|
})
|
38
|
+
|
39
|
+
it("should render a button with the given selectedClass", () => {
|
40
|
+
const wrapper = shallow(<VoteButton votes={10} buttonClassName="vote-button" iconName="vote-icon" voteAction={voteAction} disabled selectedClass="is-vote-selected" />);
|
41
|
+
expect(wrapper.find('.is-vote-selected')).to.be.present();
|
42
|
+
})
|
38
43
|
});
|