diff --git a/.changeset/message-parser-joinEmoji-tests.md b/.changeset/message-parser-joinEmoji-tests.md new file mode 100644 index 0000000000000..825e488eb1a92 --- /dev/null +++ b/.changeset/message-parser-joinEmoji-tests.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/message-parser": patch +--- + +Add test coverage for joinEmoji behavior through reducePlainTexts diff --git a/packages/message-parser/tests/joinEmoji.test.ts b/packages/message-parser/tests/joinEmoji.test.ts new file mode 100644 index 0000000000000..98e7ed1f7f78f --- /dev/null +++ b/packages/message-parser/tests/joinEmoji.test.ts @@ -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', + }); + }); +}); \ No newline at end of file