diff options
author | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-06-23 20:02:11 +0100 |
---|---|---|
committer | Jack Davison <jack.davison@student.manchester.ac.uk> | 2016-08-17 21:25:39 +0100 |
commit | 1fc17a8a43a87af89358953364872d565d38b8e8 (patch) | |
tree | 5021b7c5ede713f48a38758c3bb965427cf87e70 /spec/javascripts | |
parent | 4fbbb8e76550fcb8103cc1bf5c8536cf598db829 (diff) | |
download | gitlab-ce-1fc17a8a43a87af89358953364872d565d38b8e8.tar.gz |
Switch to using to_sentence to construct tooltips
* Code in ruby now uses Array#to_sentence to construct award tooltips
* Coffeescript uses a combination of regexes for the same result
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/awards_handler_spec.js | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/spec/javascripts/awards_handler_spec.js b/spec/javascripts/awards_handler_spec.js index 70191026d0e..7d28a61558a 100644 --- a/spec/javascripts/awards_handler_spec.js +++ b/spec/javascripts/awards_handler_spec.js @@ -144,28 +144,49 @@ }); }); describe('::addMeToUserList', function() { - return it('should prepend "me" to the award tooltip', function() { + it('should prepend "me" to the award tooltip', function() { var $thumbsUpEmoji, $votesBlock, awardUrl; awardUrl = awardsHandler.getAwardUrl(); $votesBlock = $('.js-awards-block').eq(0); $thumbsUpEmoji = $votesBlock.find('[data-emoji=thumbsup]').parent(); - $thumbsUpEmoji.attr('data-title', 'sam, jerry, max, andy'); + $thumbsUpEmoji.attr('data-title', 'sam, jerry, max, and andy'); awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); $thumbsUpEmoji.tooltip(); - return expect($thumbsUpEmoji.data("original-title")).toBe('me, sam, jerry, max, andy'); + return expect($thumbsUpEmoji.data("original-title")).toBe('me, sam, jerry, max, and andy'); + }); + return it('handles the special case where "me" is not cleanly comma seperated', function() { + var $thumbsUpEmoji, $votesBlock, awardUrl; + awardUrl = awardsHandler.getAwardUrl(); + $votesBlock = $('.js-awards-block').eq(0); + $thumbsUpEmoji = $votesBlock.find('[data-emoji=thumbsup]').parent(); + $thumbsUpEmoji.attr('data-title', 'sam'); + awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); + $thumbsUpEmoji.tooltip(); + return expect($thumbsUpEmoji.data("original-title")).toBe('me and sam'); }); }); describe('::removeMeToUserList', function() { - return it('removes "me" from the front of the tooltip', function() { + it('removes "me" from the front of the tooltip', function() { + var $thumbsUpEmoji, $votesBlock, awardUrl; + awardUrl = awardsHandler.getAwardUrl(); + $votesBlock = $('.js-awards-block').eq(0); + $thumbsUpEmoji = $votesBlock.find('[data-emoji=thumbsup]').parent(); + $thumbsUpEmoji.attr('data-title', 'me, sam, jerry, max, and andy'); + $thumbsUpEmoji.addClass('active'); + awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); + $thumbsUpEmoji.tooltip(); + return expect($thumbsUpEmoji.data("original-title")).toBe('sam, jerry, max, and andy'); + }); + return it('handles the special case where "me" is not cleanly comma seperated', function() { var $thumbsUpEmoji, $votesBlock, awardUrl; awardUrl = awardsHandler.getAwardUrl(); $votesBlock = $('.js-awards-block').eq(0); $thumbsUpEmoji = $votesBlock.find('[data-emoji=thumbsup]').parent(); - $thumbsUpEmoji.attr('data-title', 'me, sam, jerry, max, andy'); + $thumbsUpEmoji.attr('data-title', 'me and sam'); $thumbsUpEmoji.addClass('active'); awardsHandler.addAward($votesBlock, awardUrl, 'thumbsup', false); $thumbsUpEmoji.tooltip(); - return expect($thumbsUpEmoji.data("original-title")).toBe('sam, jerry, max, andy'); + return expect($thumbsUpEmoji.data("original-title")).toBe('sam'); }); }); describe('search', function() { |