import emojify from '../emoji'; describe('emoji', () => { describe('.emojify', () => { it('ignores unknown shortcodes', () => { expect(emojify(':foobarbazfake:')).toEqual(':foobarbazfake:'); }); it('ignores shortcodes inside of tags', () => { expect(emojify('

')).toEqual('

'); }); it('works with unclosed tags', () => { expect(emojify('hello>')).toEqual('hello>'); expect(emojify(' { expect(emojify('smile:')).toEqual('smile:'); expect(emojify(':smile')).toEqual(':smile'); }); it('does unicode', () => { expect(emojify('\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66')).toEqual( 'πŸ‘©β€πŸ‘©β€πŸ‘¦β€πŸ‘¦'); expect(emojify('πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘§')).toEqual( 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘§'); expect(emojify('πŸ‘©β€πŸ‘©β€πŸ‘¦')).toEqual('πŸ‘©β€πŸ‘©β€πŸ‘¦'); expect(emojify('\u2757')).toEqual( '❗'); }); it('does multiple unicode', () => { expect(emojify('\u2757 #\uFE0F\u20E3')).toEqual( '❗ #️⃣'); expect(emojify('\u2757#\uFE0F\u20E3')).toEqual( '❗#️⃣'); expect(emojify('\u2757 #\uFE0F\u20E3 \u2757')).toEqual( '❗ #️⃣ ❗'); expect(emojify('foo \u2757 #\uFE0F\u20E3 bar')).toEqual( 'foo ❗ #️⃣ bar'); }); it('ignores unicode inside of tags', () => { expect(emojify('

')).toEqual('

'); }); it('does multiple emoji properly (issue 5188)', () => { expect(emojify('πŸ‘ŒπŸŒˆπŸ’•')).toEqual('πŸ‘ŒπŸŒˆπŸ’•'); expect(emojify('πŸ‘Œ 🌈 πŸ’•')).toEqual('πŸ‘Œ 🌈 πŸ’•'); }); it('does an emoji that has no shortcode', () => { expect(emojify('πŸ‘β€πŸ—¨')).toEqual('πŸ‘β€πŸ—¨'); }); it('does an emoji whose filename is irregular', () => { expect(emojify('↙️')).toEqual('↙️'); }); it('avoid emojifying on invisible text', () => { expect(emojify('example.com/te')) .toEqual('example.com/te'); expect(emojify('', { ':luigi:': { static_url: 'luigi.exe' } })) .toEqual(''); }); it('avoid emojifying on invisible text with nested tags', () => { expect(emojify('πŸ˜‡')) .toEqual('πŸ˜‡'); expect(emojify('πŸ˜‡')) .toEqual('πŸ˜‡'); expect(emojify('πŸ˜‡')) .toEqual('πŸ˜‡'); }); it('skips the textual presentation VS15 character', () => { expect(emojify('✴︎')) // This is U+2734 EIGHT POINTED BLACK STAR then U+FE0E VARIATION SELECTOR-15 .toEqual('✴'); }); it('does an simple emoji properly', () => { expect(emojify('♀♂')) .toEqual('♀♂'); }); it('does an emoji containing ZWJ properly', () => { expect(emojify('πŸ’‚β€β™€οΈπŸ’‚β€β™‚οΈ')) .toEqual('πŸ’‚\u200Dβ™€οΈπŸ’‚\u200D♂️'); }); }); });