Make ALLOWED_EMOJI slightly configurable to let tests pass
This commit is contained in:
parent
7db74c7080
commit
02228d41e5
2 changed files with 15 additions and 6 deletions
|
@ -8,6 +8,15 @@ import {
|
|||
} from '../emoji_reacts';
|
||||
import { fromJS } from 'immutable';
|
||||
|
||||
const ALLOWED_EMOJI = [
|
||||
'👍',
|
||||
'❤',
|
||||
'😂',
|
||||
'😯',
|
||||
'😢',
|
||||
'😡',
|
||||
];
|
||||
|
||||
describe('filterEmoji', () => {
|
||||
describe('with a mix of allowed and disallowed emoji', () => {
|
||||
const emojiReacts = fromJS([
|
||||
|
@ -20,7 +29,7 @@ describe('filterEmoji', () => {
|
|||
{ 'count': 1, 'me': true, 'name': '😠' },
|
||||
]);
|
||||
it('filters only allowed emoji', () => {
|
||||
expect(filterEmoji(emojiReacts)).toEqual(fromJS([
|
||||
expect(filterEmoji(emojiReacts, ALLOWED_EMOJI)).toEqual(fromJS([
|
||||
{ 'count': 1, 'me': true, 'name': '😂' },
|
||||
{ 'count': 1, 'me': true, 'name': '😡' },
|
||||
]));
|
||||
|
@ -106,7 +115,7 @@ describe('reduceEmoji', () => {
|
|||
{ 'count': 1, 'me': false, 'name': '🍩' },
|
||||
]);
|
||||
it('sorts, filters, and combines emoji and favourites', () => {
|
||||
expect(reduceEmoji(emojiReacts, 7, true)).toEqual(fromJS([
|
||||
expect(reduceEmoji(emojiReacts, 7, true, ALLOWED_EMOJI)).toEqual(fromJS([
|
||||
{ 'count': 27, 'me': true, 'name': '👍' },
|
||||
{ 'count': 15, 'me': true, 'name': '❤' },
|
||||
{ 'count': 7, 'me': true, 'name': '😯' },
|
||||
|
|
|
@ -65,15 +65,15 @@ export const oneEmojiPerAccount = (emojiReacts, me) => {
|
|||
.reverse();
|
||||
};
|
||||
|
||||
export const filterEmoji = emojiReacts => (
|
||||
export const filterEmoji = (emojiReacts, allowedEmoji=ALLOWED_EMOJI) => (
|
||||
emojiReacts.filter(emojiReact => (
|
||||
ALLOWED_EMOJI.includes(emojiReact.get('name'))
|
||||
allowedEmoji.includes(emojiReact.get('name'))
|
||||
)));
|
||||
|
||||
export const reduceEmoji = (emojiReacts, favouritesCount, favourited) => (
|
||||
export const reduceEmoji = (emojiReacts, favouritesCount, favourited, allowedEmoji=ALLOWED_EMOJI) => (
|
||||
filterEmoji(sortEmoji(mergeEmoji(mergeEmojiFavourites(
|
||||
emojiReacts, favouritesCount, favourited
|
||||
)))));
|
||||
))), allowedEmoji));
|
||||
|
||||
export const getReactForStatus = status => {
|
||||
return reduceEmoji(
|
||||
|
|
Loading…
Reference in a new issue