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('http://example.com/testπ'))
.toEqual('http://example.com/testπ');
expect(emojify(':luigi:', { ':luigi:': { static_url: 'luigi.exe' } }))
.toEqual(':luigi:');
});
it('avoid emojifying on invisible text with nested tags', () => {
expect(emojify('πbarπ΄π'))
.toEqual('πbarπ΄');
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('');
});
it('keeps ordering as expected (issue fixed by PR 20677)', () => {
expect(emojify('π #foo test: foo.
'))
.toEqual(' #foo test: foo.
');
});
});
});