diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2017-03-17 00:32:30 +0000 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2017-03-17 00:32:30 +0000 |
commit | 4bf4612cfbe73845391375bf721592426d7b4181 (patch) | |
tree | d0d76c8c45129cdbc46c8789b85a3c8e724dacf3 /spec/javascripts | |
parent | 13b1e4fe33f25b5f03a9e3cc164c75ef9a6ad59f (diff) | |
parent | a8a52a587d6fcb618c0cadc5c405f6d1d8e820ea (diff) | |
download | gitlab-ce-4bf4612cfbe73845391375bf721592426d7b4181.tar.gz |
Merge branch 'fix-unknown-emojis-in-frequently-used-awards' into 'master'
Protect against unknown emojis in frequently used list
See merge request !10020
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/awards_handler_spec.js | 14 | ||||
-rw-r--r-- | spec/javascripts/gl_emoji_spec.js | 36 |
2 files changed, 50 insertions, 0 deletions
diff --git a/spec/javascripts/awards_handler_spec.js b/spec/javascripts/awards_handler_spec.js index 0a6e042b700..ea7753c7a1d 100644 --- a/spec/javascripts/awards_handler_spec.js +++ b/spec/javascripts/awards_handler_spec.js @@ -287,6 +287,20 @@ import AwardsHandler from '~/awards_handler'; done.fail(`Failed to open and build emoji menu: ${err.message}`); }); }); + + it('should disregard invalid frequently used emoji that are being attempted to be added', function() { + awardsHandler.addEmojiToFrequentlyUsedList('8ball'); + awardsHandler.addEmojiToFrequentlyUsedList('invalid_emoji'); + awardsHandler.addEmojiToFrequentlyUsedList('grinning'); + + expect(awardsHandler.getFrequentlyUsedEmojis()).toEqual(['8ball', 'grinning']); + }); + + it('should disregard invalid frequently used emoji already set in cookie', function() { + Cookies.set('frequently_used_emojis', '8ball,invalid_emoji,grinning'); + + expect(awardsHandler.getFrequentlyUsedEmojis()).toEqual(['8ball', 'grinning']); + }); }); }); }).call(window); diff --git a/spec/javascripts/gl_emoji_spec.js b/spec/javascripts/gl_emoji_spec.js index 9b44b25980c..b2b46640e5b 100644 --- a/spec/javascripts/gl_emoji_spec.js +++ b/spec/javascripts/gl_emoji_spec.js @@ -43,6 +43,11 @@ const emojiFixtureMap = { moji: '5️⃣', unicodeVersion: '3.0', }, + grey_question: { + name: 'grey_question', + moji: '❔', + unicodeVersion: '6.0', + }, }; function markupToDomElement(markup) { @@ -153,6 +158,37 @@ describe('gl_emoji', () => { }, ); }); + + it('question mark when invalid emoji name given', () => { + const name = 'invalid_emoji'; + const emojiKey = 'grey_question'; + const markup = glEmojiTag(name); + const glEmojiElement = markupToDomElement(markup); + testGlEmojiElement( + glEmojiElement, + emojiFixtureMap[emojiKey].name, + emojiFixtureMap[emojiKey].unicodeVersion, + emojiFixtureMap[emojiKey].moji, + ); + }); + + it('question mark with image fallback when invalid emoji name given', () => { + const name = 'invalid_emoji'; + const emojiKey = 'grey_question'; + const markup = glEmojiTag(name, { + forceFallback: true, + }); + const glEmojiElement = markupToDomElement(markup); + testGlEmojiElement( + glEmojiElement, + emojiFixtureMap[emojiKey].name, + emojiFixtureMap[emojiKey].unicodeVersion, + emojiFixtureMap[emojiKey].moji, + { + forceFallback: true, + }, + ); + }); }); describe('isFlagEmoji', () => { |