diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-03-09 11:55:18 -0600 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-03-09 13:00:46 -0600 |
commit | 3f5919e2c44ac7b18f06647342476ad5c3d757ba (patch) | |
tree | e06775a5f492150b7766157918e9707bc763c13a /spec | |
parent | 130fd255bc0735d4175f2db2770a9092882fa3a4 (diff) | |
download | gitlab-ce-3f5919e2c44ac7b18f06647342476ad5c3d757ba.tar.gz |
Add frequently used emojis back to awards menuadd-frequently-used-emojis-back-to-menu
Thanks @filipa for the shout`
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/awards_handler_spec.js | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/spec/javascripts/awards_handler_spec.js b/spec/javascripts/awards_handler_spec.js index dc0a62ade50..9a2978006aa 100644 --- a/spec/javascripts/awards_handler_spec.js +++ b/spec/javascripts/awards_handler_spec.js @@ -1,6 +1,7 @@ /* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, no-unused-expressions, comma-dangle, new-parens, no-unused-vars, quotes, jasmine/no-spec-dupes, prefer-template, max-len */ import promisePolyfill from 'es6-promise'; +import Cookies from 'js-cookie'; import AwardsHandler from '~/awards_handler'; promisePolyfill.polyfill(); @@ -208,8 +209,8 @@ promisePolyfill.polyfill(); expect($('[data-name=alien]').is(':visible')).toBe(true); }) .then(done) - .catch(() => { - done.fail('Failed to open and build emoji menu'); + .catch((err) => { + done.fail(`Failed to open and build emoji menu: ${err.message}`); }); }); }); @@ -232,8 +233,8 @@ promisePolyfill.polyfill(); it('should add selected emoji to awards block', function(done) { return openEmojiMenuAndAddEmoji() .then(done) - .catch(() => { - done.fail('Failed to open and build emoji menu'); + .catch((err) => { + done.fail(`Failed to open and build emoji menu: ${err.message}`); }); }); it('should remove already selected emoji', function(done) { @@ -247,7 +248,46 @@ promisePolyfill.polyfill(); }) .then(done) .catch((err) => { - done.fail('Failed to open and build emoji menu'); + done.fail(`Failed to open and build emoji menu: ${err.message}`); + }); + }); + }); + + describe('frequently used emojis', function() { + beforeEach(() => { + // Clear it out + Cookies.set('frequently_used_emojis', ''); + }); + + it('shouldn\'t have any "Frequently used" heading if no frequently used emojis', function(done) { + return openAndWaitForEmojiMenu() + .then(() => { + const emojiMenu = document.querySelector('.emoji-menu'); + Array.prototype.forEach.call(emojiMenu.querySelectorAll('.emoji-menu-title'), (title) => { + expect(title.textContent.trim().toLowerCase()).not.toBe('frequently used'); + }); + }) + .then(done) + .catch((err) => { + done.fail(`Failed to open and build emoji menu: ${err.message}`); + }); + }); + + it('should have any frequently used section when there are frequently used emojis', function(done) { + awardsHandler.addEmojiToFrequentlyUsedList('8ball'); + + return openAndWaitForEmojiMenu() + .then(() => { + const emojiMenu = document.querySelector('.emoji-menu'); + const hasFrequentlyUsedHeading = Array.prototype.some.call(emojiMenu.querySelectorAll('.emoji-menu-title'), title => + title.textContent.trim().toLowerCase() === 'frequently used' + ); + + expect(hasFrequentlyUsedHeading).toBe(true); + }) + .then(done) + .catch((err) => { + done.fail(`Failed to open and build emoji menu: ${err.message}`); }); }); }); |