From e28258010182b56f27cfbd3f9f9a58fd9cd8870d Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Mon, 3 Jul 2017 02:02:36 -0700 Subject: Faster emojify() by avoiding str.replace() entirely (#4049) --- spec/javascript/components/emojify.test.js | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'spec') diff --git a/spec/javascript/components/emojify.test.js b/spec/javascript/components/emojify.test.js index 7a496623e..3e8b25af9 100644 --- a/spec/javascript/components/emojify.test.js +++ b/spec/javascript/components/emojify.test.js @@ -46,4 +46,38 @@ describe('emojify', () => { expect(emojify(':smile')).to.equal(':smile'); }); + it('does two emoji next to each other', () => { + expect(emojify(':smile::wink:')).to.equal( + '😄😉'); + }); + + it('does unicode', () => { + expect(emojify('\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66')).to.equal( + '👩‍👩‍👦‍👦'); + expect(emojify('\uD83D\uDC68\uD83D\uDC69\uD83D\uDC67\uD83D\uDC67')).to.equal( + '👨👩👧👧'); + expect(emojify('\uD83D\uDC69\uD83D\uDC69\uD83D\uDC66')).to.equal('👩👩👦'); + expect(emojify('\u2757')).to.equal( + '❗'); + }); + + it('does multiple unicode', () => { + expect(emojify('\u2757 #\uFE0F\u20E3')).to.equal( + '❗ #️⃣'); + expect(emojify('\u2757#\uFE0F\u20E3')).to.equal( + '❗#️⃣'); + expect(emojify('\u2757 #\uFE0F\u20E3 \u2757')).to.equal( + '❗ #️⃣ ❗'); + expect(emojify('foo \u2757 #\uFE0F\u20E3 bar')).to.equal( + 'foo ❗ #️⃣ bar'); + }); + + it('does mixed unicode and shortnames', () => { + expect(emojify(':smile:#\uFE0F\u20E3:wink:\u2757')).to.equal('😄#️⃣😉❗'); + }); + + it('ignores unicode inside of tags', () => { + expect(emojify('

')).to.equal('

'); + }); + }); -- cgit