From 5c4cf3b3a37a2b97ff578ce6a1296e8fc1774abc Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 10 Dec 2018 13:21:13 +0100 Subject: [PATCH] Move emoji_menu_spec.js to Jest --- app/assets/javascripts/pages/profiles/show/emoji_menu.js | 1 + config/jest.config.js | 1 + spec/frontend/helpers/test_constants.js | 2 ++ .../pages/profiles/show/emoji_menu_spec.js | 6 +++--- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 spec/frontend/helpers/test_constants.js rename spec/{javascripts => frontend}/pages/profiles/show/emoji_menu_spec.js (94%) diff --git a/app/assets/javascripts/pages/profiles/show/emoji_menu.js b/app/assets/javascripts/pages/profiles/show/emoji_menu.js index 094837b40e0..286c1f1e929 100644 --- a/app/assets/javascripts/pages/profiles/show/emoji_menu.js +++ b/app/assets/javascripts/pages/profiles/show/emoji_menu.js @@ -1,3 +1,4 @@ +import '~/commons/bootstrap'; import { AwardsHandler } from '~/awards_handler'; class EmojiMenu extends AwardsHandler { diff --git a/config/jest.config.js b/config/jest.config.js index 23e62f49be1..e1b07f21555 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -16,6 +16,7 @@ module.exports = { testMatch: ['/spec/frontend/**/*_spec.js'], moduleNameMapper: { '^~(.*)$': '/app/assets/javascripts$1', + '^helpers(.*)$': '/spec/frontend/helpers$1', }, collectCoverageFrom: ['/app/assets/javascripts/**/*.{js,vue}'], coverageDirectory: '/coverage-frontend/', diff --git a/spec/frontend/helpers/test_constants.js b/spec/frontend/helpers/test_constants.js new file mode 100644 index 00000000000..8dc4aef87e1 --- /dev/null +++ b/spec/frontend/helpers/test_constants.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line import/prefer-default-export +export const TEST_HOST = 'http://test.host'; diff --git a/spec/javascripts/pages/profiles/show/emoji_menu_spec.js b/spec/frontend/pages/profiles/show/emoji_menu_spec.js similarity index 94% rename from spec/javascripts/pages/profiles/show/emoji_menu_spec.js rename to spec/frontend/pages/profiles/show/emoji_menu_spec.js index 864bda65736..efc338b36eb 100644 --- a/spec/javascripts/pages/profiles/show/emoji_menu_spec.js +++ b/spec/frontend/pages/profiles/show/emoji_menu_spec.js @@ -1,7 +1,7 @@ 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'; +import { TEST_HOST } from 'helpers/test_constants'; describe('EmojiMenu', () => { const dummyEmojiTag = ''; @@ -56,7 +56,7 @@ describe('EmojiMenu', () => { }); it('does not make an axios requst', done => { - spyOn(axios, 'request').and.stub(); + jest.spyOn(axios, 'request').mockReturnValue(); emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => { expect(axios.request).not.toHaveBeenCalled(); @@ -67,7 +67,7 @@ describe('EmojiMenu', () => { describe('bindEvents', () => { beforeEach(() => { - spyOn(emojiMenu, 'registerEventListener').and.stub(); + jest.spyOn(emojiMenu, 'registerEventListener').mockReturnValue(); }); it('binds event listeners to custom toggle button', () => {