Fix tests
This commit is contained in:
parent
cc1b478e3f
commit
d738e7d5bf
|
@ -561,21 +561,26 @@ class StatusActionBar extends ImmutablePureComponent<IStatusActionBar, IStatusAc
|
||||||
const replyCount = status.replies_count;
|
const replyCount = status.replies_count;
|
||||||
const reblogCount = status.reblogs_count;
|
const reblogCount = status.reblogs_count;
|
||||||
const favouriteCount = status.favourites_count;
|
const favouriteCount = status.favourites_count;
|
||||||
|
|
||||||
const emojiReactCount = reduceEmoji(
|
const emojiReactCount = reduceEmoji(
|
||||||
(status.getIn(['pleroma', 'emoji_reactions']) || ImmutableList()) as ImmutableList<any>,
|
(status.getIn(['pleroma', 'emoji_reactions']) || ImmutableList()) as ImmutableList<any>,
|
||||||
favouriteCount,
|
favouriteCount,
|
||||||
status.favourited,
|
status.favourited,
|
||||||
allowedEmoji,
|
allowedEmoji,
|
||||||
).reduce((acc, cur) => acc + cur.get('count'), 0);
|
).reduce((acc, cur) => acc + cur.get('count'), 0);
|
||||||
const meEmojiReact = getReactForStatus(status, allowedEmoji);
|
|
||||||
const meEmojiTitle = intl.formatMessage({
|
const meEmojiReact = getReactForStatus(status, allowedEmoji) as keyof typeof reactMessages | undefined;
|
||||||
|
|
||||||
|
const reactMessages = {
|
||||||
'👍': messages.reactionLike,
|
'👍': messages.reactionLike,
|
||||||
'❤️': messages.reactionHeart,
|
'❤️': messages.reactionHeart,
|
||||||
'😆': messages.reactionLaughing,
|
'😆': messages.reactionLaughing,
|
||||||
'😮': messages.reactionOpenMouth,
|
'😮': messages.reactionOpenMouth,
|
||||||
'😢': messages.reactionCry,
|
'😢': messages.reactionCry,
|
||||||
'😩': messages.reactionWeary,
|
'😩': messages.reactionWeary,
|
||||||
}[meEmojiReact] || messages.favourite);
|
};
|
||||||
|
|
||||||
|
const meEmojiTitle = intl.formatMessage(meEmojiReact ? reactMessages[meEmojiReact] : messages.favourite);
|
||||||
|
|
||||||
const menu = this._makeMenu(publicStatus);
|
const menu = this._makeMenu(publicStatus);
|
||||||
let reblogIcon = require('@tabler/icons/icons/repeat.svg');
|
let reblogIcon = require('@tabler/icons/icons/repeat.svg');
|
||||||
|
@ -587,18 +592,15 @@ class StatusActionBar extends ImmutablePureComponent<IStatusActionBar, IStatusAc
|
||||||
reblogIcon = require('@tabler/icons/icons/lock.svg');
|
reblogIcon = require('@tabler/icons/icons/lock.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
const reblogMenu = [
|
const reblogMenu = [{
|
||||||
{
|
|
||||||
text: intl.formatMessage(status.reblogged ? messages.cancel_reblog_private : messages.reblog),
|
text: intl.formatMessage(status.reblogged ? messages.cancel_reblog_private : messages.reblog),
|
||||||
action: this.handleReblogClick,
|
action: this.handleReblogClick,
|
||||||
icon: require('@tabler/icons/icons/repeat.svg'),
|
icon: require('@tabler/icons/icons/repeat.svg'),
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.quotePost),
|
text: intl.formatMessage(messages.quotePost),
|
||||||
action: this.handleQuoteClick,
|
action: this.handleQuoteClick,
|
||||||
icon: require('@tabler/icons/icons/quote.svg'),
|
icon: require('@tabler/icons/icons/quote.svg'),
|
||||||
},
|
}];
|
||||||
];
|
|
||||||
|
|
||||||
const reblogButton = (
|
const reblogButton = (
|
||||||
<StatusActionButton
|
<StatusActionButton
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
// import { fromJS } from 'immutable';
|
import { AccountRecord } from 'soapbox/normalizers';
|
||||||
//
|
|
||||||
// import {
|
import {
|
||||||
// getDomain,
|
getDomain,
|
||||||
// } from '../accounts';
|
} from '../accounts';
|
||||||
//
|
|
||||||
// describe('getDomain', () => {
|
describe('getDomain', () => {
|
||||||
// const account = fromJS({
|
const account = AccountRecord({
|
||||||
// acct: 'alice',
|
acct: 'alice',
|
||||||
// url: 'https://party.com/users/alice',
|
url: 'https://party.com/users/alice',
|
||||||
// });
|
});
|
||||||
// it('returns the domain', () => {
|
it('returns the domain', () => {
|
||||||
// expect(getDomain(account)).toEqual('party.com');
|
expect(getDomain(account)).toEqual('party.com');
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
|
@ -11,14 +11,14 @@ import {
|
||||||
simulateUnEmojiReact,
|
simulateUnEmojiReact,
|
||||||
} from '../emoji_reacts';
|
} from '../emoji_reacts';
|
||||||
|
|
||||||
const ALLOWED_EMOJI = [
|
const ALLOWED_EMOJI = fromJS([
|
||||||
'👍',
|
'👍',
|
||||||
'❤',
|
'❤',
|
||||||
'😂',
|
'😂',
|
||||||
'😯',
|
'😯',
|
||||||
'😢',
|
'😢',
|
||||||
'😡',
|
'😡',
|
||||||
];
|
]);
|
||||||
|
|
||||||
describe('filterEmoji', () => {
|
describe('filterEmoji', () => {
|
||||||
describe('with a mix of allowed and disallowed emoji', () => {
|
describe('with a mix of allowed and disallowed emoji', () => {
|
||||||
|
@ -168,7 +168,7 @@ describe('getReactForStatus', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns undefined when a status has no reacts (or favourites)', () => {
|
it('returns undefined when a status has no reacts (or favourites)', () => {
|
||||||
const status = fromJS([]);
|
const status = fromJS({});
|
||||||
expect(getReactForStatus(status)).toEqual(undefined);
|
expect(getReactForStatus(status)).toEqual(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -80,21 +80,23 @@ export const reduceEmoji = (emojiReacts: ImmutableList<EmojiReact>, favouritesCo
|
||||||
emojiReacts, favouritesCount, favourited,
|
emojiReacts, favouritesCount, favourited,
|
||||||
))), allowedEmoji));
|
))), allowedEmoji));
|
||||||
|
|
||||||
export const getReactForStatus = (status: any, allowedEmoji=ALLOWED_EMOJI): string => {
|
export const getReactForStatus = (status: any, allowedEmoji=ALLOWED_EMOJI): string | undefined => {
|
||||||
return String(reduceEmoji(
|
const result = reduceEmoji(
|
||||||
status.getIn(['pleroma', 'emoji_reactions'], ImmutableList()),
|
status.getIn(['pleroma', 'emoji_reactions'], ImmutableList()),
|
||||||
status.get('favourites_count', 0),
|
status.get('favourites_count', 0),
|
||||||
status.get('favourited'),
|
status.get('favourited'),
|
||||||
allowedEmoji,
|
allowedEmoji,
|
||||||
).filter(e => e.get('me') === true)
|
).filter(e => e.get('me') === true)
|
||||||
.getIn([0, 'name'], ''));
|
.getIn([0, 'name']);
|
||||||
|
|
||||||
|
return typeof result === 'string' ? result : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const simulateEmojiReact = (emojiReacts: ImmutableList<EmojiReact>, emoji: string) => {
|
export const simulateEmojiReact = (emojiReacts: ImmutableList<EmojiReact>, emoji: string) => {
|
||||||
const idx = emojiReacts.findIndex(e => e.get('name') === emoji);
|
const idx = emojiReacts.findIndex(e => e.get('name') === emoji);
|
||||||
const emojiReact = emojiReacts.get(idx);
|
const emojiReact = emojiReacts.get(idx);
|
||||||
|
|
||||||
if (emojiReact) {
|
if (idx > -1 && emojiReact) {
|
||||||
return emojiReacts.set(idx, emojiReact.merge({
|
return emojiReacts.set(idx, emojiReact.merge({
|
||||||
count: emojiReact.get('count') + 1,
|
count: emojiReact.get('count') + 1,
|
||||||
me: true,
|
me: true,
|
||||||
|
|
Loading…
Reference in New Issue