Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

support new reaction emoji from GitHub.com #1985

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions lib/views/emoji-reactions-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const reactionTypeToEmoji = {
HOORAY: '🎉',
CONFUSED: '😕',
HEART: '❤️',
ROCKET: '🚀',
EYES: '👀',
};

export default class EmojiReactionsView extends React.Component {
Expand All @@ -26,14 +28,19 @@ export default class EmojiReactionsView extends React.Component {
render() {
return (
<div className="github-IssueishDetailView-reactions">
{this.props.reactionGroups.map(group => (
group.users.totalCount > 0
? <span className={cx('github-IssueishDetailView-reactionsGroup', group.content.toLowerCase())}
key={group.content}>
{reactionTypeToEmoji[group.content]} &nbsp; {group.users.totalCount}
</span>
: null
))}
{this.props.reactionGroups.map(group => {
const emoji = reactionTypeToEmoji[group.content];
if (!emoji) {
return null;
}
return (
group.users.totalCount > 0
? <span className={cx('github-IssueishDetailView-reactionsGroup', group.content.toLowerCase())}
key={group.content}>
{reactionTypeToEmoji[group.content]} &nbsp; {group.users.totalCount}
</span>
: null);
})}
</div>
);
}
Expand Down
10 changes: 10 additions & 0 deletions test/views/emoji-reactions-view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ describe('EmojiReactionsView', function() {
const reactionGroups = [
{content: 'THUMBS_UP', users: {totalCount: 10}},
{content: 'THUMBS_DOWN', users: {totalCount: 5}},
{content: 'ROCKET', users: {totalCount: 42}},
{content: 'EYES', users: {totalCount: 13}},
{content: 'AVOCADO', users: {totalCount: 11}},
{content: 'LAUGH', users: {totalCount: 0}}];
beforeEach(function() {
wrapper = shallow(<EmojiReactionsView reactionGroups={reactionGroups} />);
Expand All @@ -15,6 +18,13 @@ describe('EmojiReactionsView', function() {
const groups = wrapper.find('.github-IssueishDetailView-reactionsGroup');
assert.lengthOf(groups.findWhere(n => /👍/u.test(n.text()) && /\b10\b/.test(n.text())), 1);
assert.lengthOf(groups.findWhere(n => /👎/u.test(n.text()) && /\b5\b/.test(n.text())), 1);
assert.lengthOf(groups.findWhere(n => /🚀/u.test(n.text()) && /\b42\b/.test(n.text())), 1);
assert.lengthOf(groups.findWhere(n => /👀/u.test(n.text()) && /\b13\b/.test(n.text())), 1);
assert.isFalse(groups.someWhere(n => /😆/u.test(n.text())));
});
it('gracefully skips unknown emoji', function() {
assert.isFalse(wrapper.text().includes(11));
const groups = wrapper.find('.github-IssueishDetailView-reactionsGroup');
assert.lengthOf(groups, 4);
});
});