diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-12-10 15:21:13 +0300 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-12-11 15:06:19 +0300 |
commit | 5c4cf3b3a37a2b97ff578ce6a1296e8fc1774abc (patch) | |
tree | 4a74cbcd4ec0d2b91091b68a33f62fc9b137ee48 /spec/javascripts/pages | |
parent | 7c4940b70236347d06d7c4b559dcc50a8e68d8c0 (diff) |
Move emoji_menu_spec.js to Jest
Diffstat (limited to 'spec/javascripts/pages')
-rw-r--r-- | spec/javascripts/pages/profiles/show/emoji_menu_spec.js | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/spec/javascripts/pages/profiles/show/emoji_menu_spec.js b/spec/javascripts/pages/profiles/show/emoji_menu_spec.js deleted file mode 100644 index 864bda65736..00000000000 --- a/spec/javascripts/pages/profiles/show/emoji_menu_spec.js +++ /dev/null @@ -1,119 +0,0 @@ -import $ from 'jquery'; -import axios from '~/lib/utils/axios_utils'; -import EmojiMenu from '~/pages/profiles/show/emoji_menu'; -import { TEST_HOST } from 'spec/test_constants'; - -describe('EmojiMenu', () => { - const dummyEmojiTag = '<dummy></tag>'; - const dummyToggleButtonSelector = '.toggle-button-selector'; - const dummyMenuClass = 'dummy-menu-class'; - - let emojiMenu; - let dummySelectEmojiCallback; - let dummyEmojiList; - - beforeEach(() => { - dummySelectEmojiCallback = jasmine.createSpy('dummySelectEmojiCallback'); - dummyEmojiList = { - glEmojiTag() { - return dummyEmojiTag; - }, - normalizeEmojiName(emoji) { - return emoji; - }, - isEmojiNameValid() { - return true; - }, - getEmojiCategoryMap() { - return { dummyCategory: [] }; - }, - }; - - emojiMenu = new EmojiMenu( - dummyEmojiList, - dummyToggleButtonSelector, - dummyMenuClass, - dummySelectEmojiCallback, - ); - }); - - afterEach(() => { - emojiMenu.destroy(); - }); - - describe('addAward', () => { - const dummyAwardUrl = `${TEST_HOST}/award/url`; - const dummyEmoji = 'tropical_fish'; - const dummyVotesBlock = () => $('<div />'); - - it('calls selectEmojiCallback', done => { - expect(dummySelectEmojiCallback).not.toHaveBeenCalled(); - - emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => { - expect(dummySelectEmojiCallback).toHaveBeenCalledWith(dummyEmoji, dummyEmojiTag); - done(); - }); - }); - - it('does not make an axios requst', done => { - spyOn(axios, 'request').and.stub(); - - emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => { - expect(axios.request).not.toHaveBeenCalled(); - done(); - }); - }); - }); - - describe('bindEvents', () => { - beforeEach(() => { - spyOn(emojiMenu, 'registerEventListener').and.stub(); - }); - - it('binds event listeners to custom toggle button', () => { - emojiMenu.bindEvents(); - - expect(emojiMenu.registerEventListener).toHaveBeenCalledWith( - 'one', - jasmine.anything(), - 'mouseenter focus', - dummyToggleButtonSelector, - 'mouseenter focus', - jasmine.anything(), - ); - - expect(emojiMenu.registerEventListener).toHaveBeenCalledWith( - 'on', - jasmine.anything(), - 'click', - dummyToggleButtonSelector, - jasmine.anything(), - ); - }); - - it('binds event listeners to custom menu class', () => { - emojiMenu.bindEvents(); - - expect(emojiMenu.registerEventListener).toHaveBeenCalledWith( - 'on', - jasmine.anything(), - 'click', - `.js-awards-block .js-emoji-btn, .${dummyMenuClass} .js-emoji-btn`, - jasmine.anything(), - ); - }); - }); - - describe('createEmojiMenu', () => { - it('renders the menu with custom menu class', () => { - const menuElement = () => - document.body.querySelector(`.emoji-menu.${dummyMenuClass} .emoji-menu-content`); - - expect(menuElement()).toBe(null); - - emojiMenu.createEmojiMenu(); - - expect(menuElement()).not.toBe(null); - }); - }); -}); |