Skip to content

Commit c3d47c4

Browse files
committed
add emoji config test to Channel
1 parent 653f458 commit c3d47c4

File tree

2 files changed

+27
-46
lines changed

2 files changed

+27
-46
lines changed

src/components/Channel/__tests__/Channel.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,32 @@ describe('Channel', () => {
216216

217217
// eslint-disable-next-line sonarjs/cognitive-complexity
218218
describe('Children that consume ChannelContext', () => {
219+
it('should expose the emoji config', async () => {
220+
let context;
221+
const emojiData = {
222+
compressed: true,
223+
categories: [],
224+
emojis: {},
225+
aliases: {},
226+
};
227+
const CustomEmojiPicker = () => <div />;
228+
const CustomEmoji = () => <span />;
229+
230+
renderComponent(
231+
{ emojiData, Emoji: CustomEmoji, EmojiPicker: CustomEmojiPicker },
232+
(ctx) => {
233+
context = ctx;
234+
},
235+
);
236+
237+
await waitFor(() => {
238+
expect(context).toBeInstanceOf(Object);
239+
expect(context.emojiConfig.emojiData).toBe(emojiData);
240+
expect(context.emojiConfig.EmojiPicker).toBe(CustomEmojiPicker);
241+
expect(context.emojiConfig.Emoji).toBe(CustomEmoji);
242+
});
243+
});
244+
219245
it('should be able to open threads', async () => {
220246
const threadMessage = messages[0];
221247
const hasThread = jest.fn();

src/components/Chat/__tests__/Chat.test.js

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import {
88
dispatchNotificationMutesUpdated,
99
} from 'mock-builders';
1010
import { Chat } from '..';
11-
import {
12-
ChatContext,
13-
EmojiContext,
14-
TranslationContext,
15-
} from '../../../context';
11+
import { ChatContext, TranslationContext } from '../../../context';
1612
import { Streami18n } from '../../../i18n';
1713

1814
import { version } from '../../../../package.json';
@@ -22,11 +18,6 @@ const ChatContextConsumer = ({ fn }) => {
2218
return <div data-testid="children" />;
2319
};
2420

25-
const EmojiContextConsumer = ({ fn }) => {
26-
fn(useContext(EmojiContext));
27-
return <div data-testid="children" />;
28-
};
29-
3021
const TranslationContextConsumer = ({ fn }) => {
3122
fn(useContext(TranslationContext));
3223
return <div data-testid="children" />;
@@ -380,40 +371,4 @@ describe('Chat', () => {
380371
});
381372
});
382373
});
383-
384-
describe('emoji context', () => {
385-
it('should expose the emoji context', async () => {
386-
let context;
387-
const emojiData = {
388-
compressed: true,
389-
categories: [],
390-
emojis: {},
391-
aliases: {},
392-
};
393-
const CustomEmojiPicker = () => <div />;
394-
const CustomEmoji = () => <span />;
395-
396-
render(
397-
<Chat
398-
client={chatClient}
399-
emojiData={emojiData}
400-
Emoji={CustomEmoji}
401-
EmojiPicker={CustomEmojiPicker}
402-
>
403-
<EmojiContextConsumer
404-
fn={(ctx) => {
405-
context = ctx;
406-
}}
407-
></EmojiContextConsumer>
408-
</Chat>,
409-
);
410-
411-
await waitFor(() => {
412-
expect(context).toBeInstanceOf(Object);
413-
expect(context.emojiData).toBe(emojiData);
414-
expect(context.EmojiPicker).toBe(CustomEmojiPicker);
415-
expect(context.Emoji).toBe(CustomEmoji);
416-
});
417-
});
418-
});
419374
});

0 commit comments

Comments
 (0)