Skip to content

Commit

Permalink
Adjust MessageSimple and ReactionsList tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Oct 13, 2023
1 parent b4ac9f8 commit 62d548d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
32 changes: 10 additions & 22 deletions src/components/Message/__tests__/MessageSimple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ import { EditMessageForm, MessageInput as MessageInputMock } from '../../Message
import { getReadStates } from '../../MessageList';
import { MML as MMLMock } from '../../MML';
import { Modal as ModalMock } from '../../Modal';
import { defaultReactionOptions } from '../../Reactions';

import {
ChannelActionProvider,
ChannelStateProvider,
ChatProvider,
ComponentProvider,
EmojiProvider,
TranslationProvider,
} from '../../../context';
import {
emojiComponentMock,
emojiDataMock,
generateChannel,
generateMessage,
generateReaction,
Expand Down Expand Up @@ -75,9 +73,7 @@ async function renderMessageSimple({

return renderer(
<ChatProvider value={{ client, themeVersion: '1' }}>
<ChannelStateProvider
value={{ channel, channelCapabilities, channelConfig, emojiConfig: emojiDataMock }}
>
<ChannelStateProvider value={{ channel, channelCapabilities, channelConfig }}>
<ChannelActionProvider
value={{ openThread: openThreadMock, retrySendMessage: retrySendMessageMock }}
>
Expand All @@ -87,25 +83,17 @@ async function renderMessageSimple({
Attachment: AttachmentMock,
// eslint-disable-next-line react/display-name
Message: () => <MessageSimple {...props} />,
reactionOptions: defaultReactionOptions,
...components,
}}
>
<EmojiProvider
value={{
Emoji: emojiComponentMock.Emoji,
emojiConfig: emojiDataMock,
EmojiIndex: emojiComponentMock.EmojiIndex,
EmojiPicker: emojiComponentMock.EmojiPicker,
}}
>
<Message
getMessageActions={() => Object.keys(MESSAGE_ACTIONS)}
isMyMessage={() => true}
message={message}
threadList={false}
{...props}
/>
</EmojiProvider>
<Message
getMessageActions={() => Object.keys(MESSAGE_ACTIONS)}
isMyMessage={() => true}
message={message}
threadList={false}
{...props}
/>
</ComponentProvider>
</TranslationProvider>
</ChannelActionProvider>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Reactions/__tests__/ReactionsList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const generateButtonTitle = (count) =>

const renderComponent = ({ reaction_counts = {}, ...props }) => {
const reactions = Object.entries(reaction_counts).flatMap(([type, count]) =>
Array(count)
.fill()
.map((_, i) => generateReaction({ type, user: { id: `${USER_ID}-${i}` } })),
Array.from({ length: count }, (_, i) =>
generateReaction({ type, user: { id: `${USER_ID}-${i}` } }),
),
);

return render(
Expand Down

0 comments on commit 62d548d

Please sign in to comment.