Hello 😊🇪🇺!
${expectedCustomEmojiImage}
`, - ); - expect(searchEmojisByHexcodes).not.toHaveBeenCalled(); - }); - - test('emojifies flag emoji in native-with-flags mode', async () => { - const { searchEmojisByHexcodes } = mockDatabase(); - const actual = await emojifyElement( - testElement(), - testAppState({ mode: EMOJI_MODE_NATIVE_WITH_FLAGS }), - ); - assert(actual); - expect(actual.innerHTML).toBe( - `Hello 😊${expectedFlagImage}!
${expectedCustomEmojiImage}
`, - ); - expect(searchEmojisByHexcodes).toHaveBeenCalledOnce(); - }); - - test('emojifies everything in twemoji mode', async () => { - const { searchCustomEmojisByShortcodes, searchEmojisByHexcodes } = - mockDatabase(); - const actual = await emojifyElement(testElement(), testAppState()); - assert(actual); - expect(actual.innerHTML).toBe( - `Hello ${expectedSmileImage}${expectedFlagImage}!
${expectedCustomEmojiImage}
`, - ); - expect(searchEmojisByHexcodes).toHaveBeenCalledOnce(); - expect(searchCustomEmojisByShortcodes).toHaveBeenCalledOnce(); - }); - - test('emojifies with provided custom emoji', async () => { - const { searchCustomEmojisByShortcodes, searchEmojisByHexcodes } = - mockDatabase(); - const actual = await emojifyElement( - testElement('hi :remote:
'), - testAppState(), - mockExtraCustom, - ); - assert(actual); - expect(actual.innerHTML).toBe( - `hi ${expectedRemoteCustomEmojiImage}
`, - ); - expect(searchEmojisByHexcodes).not.toHaveBeenCalled(); - expect(searchCustomEmojisByShortcodes).not.toHaveBeenCalled(); - }); - test('returns null when no emoji are found', async () => { mockDatabase(); const actual = await emojifyElement( @@ -165,28 +95,9 @@ describe('emojifyText', () => { const actual = await emojifyText('Hello 😊🇪🇺!', testAppState()); expect(actual).toBe(`Hello ${expectedSmileImage}${expectedFlagImage}!`); }); - - test('renders custom emojis', async () => { - mockDatabase(); - const actual = await emojifyText('Hello :custom:!', testAppState()); - expect(actual).toBe(`Hello ${expectedCustomEmojiImage}!`); - }); - - test('renders provided extra emojis', async () => { - const actual = await emojifyText( - 'remote emoji :remote:', - testAppState(), - mockExtraCustom, - ); - expect(actual).toBe(`remote emoji ${expectedRemoteCustomEmojiImage}`); - }); }); describe('tokenizeText', () => { - test('returns empty array for string with only whitespace', () => { - expect(tokenizeText(' \n')).toEqual([]); - }); - test('returns an array of text to be a single token', () => { expect(tokenizeText('Hello')).toEqual(['Hello']); }); @@ -212,7 +123,7 @@ describe('tokenizeText', () => { 'Hello ', { type: 'custom', - code: 'smile', + code: ':smile:', }, '!!', ]); @@ -223,7 +134,7 @@ describe('tokenizeText', () => { 'Hello ', { type: 'custom', - code: 'smile_123', + code: ':smile_123:', }, '!!', ]); @@ -239,7 +150,7 @@ describe('tokenizeText', () => { ' ', { type: 'custom', - code: 'smile', + code: ':smile:', }, '!!', ]);