Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/message-parser-joinEmoji-tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/message-parser": patch
---

Add test coverage for joinEmoji behavior through reducePlainTexts
32 changes: 32 additions & 0 deletions packages/message-parser/tests/joinEmoji.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { plain, emoji, reducePlainTexts } from '../src/utils';

describe('joinEmoji behavior through reducePlainTexts', () => {
it('keeps emoji when alone', () => {
const result = reducePlainTexts([emoji('smile')]);
expect(result[0].type).toBe('EMOJI');
});

it('merges consecutive plain texts', () => {
const result = reducePlainTexts([
plain('hello '),
plain('world'),
]);

expect(result).toHaveLength(1);
expect(result[0]).toMatchObject({ type: 'PLAIN_TEXT', value: 'hello world' });
});

it('converts emoji with plain text neighbors to shortCode and merges', () => {
const result = reducePlainTexts([
plain('hello'),
emoji('smile'),
plain('world'),
]);

expect(result).toHaveLength(1);
expect(result[0]).toMatchObject({
type: 'PLAIN_TEXT',
value: 'hello:smile:world',
});
});
});