Commit 5c4cf3b3 authored by Winnie Hellmann's avatar Winnie Hellmann

Move emoji_menu_spec.js to Jest

parent 7c4940b7
import '~/commons/bootstrap';
import { AwardsHandler } from '~/awards_handler'; import { AwardsHandler } from '~/awards_handler';
class EmojiMenu extends AwardsHandler { class EmojiMenu extends AwardsHandler {
......
...@@ -16,6 +16,7 @@ module.exports = { ...@@ -16,6 +16,7 @@ module.exports = {
testMatch: ['<rootDir>/spec/frontend/**/*_spec.js'], testMatch: ['<rootDir>/spec/frontend/**/*_spec.js'],
moduleNameMapper: { moduleNameMapper: {
'^~(.*)$': '<rootDir>/app/assets/javascripts$1', '^~(.*)$': '<rootDir>/app/assets/javascripts$1',
'^helpers(.*)$': '<rootDir>/spec/frontend/helpers$1',
}, },
collectCoverageFrom: ['<rootDir>/app/assets/javascripts/**/*.{js,vue}'], collectCoverageFrom: ['<rootDir>/app/assets/javascripts/**/*.{js,vue}'],
coverageDirectory: '<rootDir>/coverage-frontend/', coverageDirectory: '<rootDir>/coverage-frontend/',
......
// eslint-disable-next-line import/prefer-default-export
export const TEST_HOST = 'http://test.host';
import $ from 'jquery'; import $ from 'jquery';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import EmojiMenu from '~/pages/profiles/show/emoji_menu'; import EmojiMenu from '~/pages/profiles/show/emoji_menu';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
describe('EmojiMenu', () => { describe('EmojiMenu', () => {
const dummyEmojiTag = '<dummy></tag>'; const dummyEmojiTag = '<dummy></tag>';
...@@ -56,7 +56,7 @@ describe('EmojiMenu', () => { ...@@ -56,7 +56,7 @@ describe('EmojiMenu', () => {
}); });
it('does not make an axios requst', done => { it('does not make an axios requst', done => {
spyOn(axios, 'request').and.stub(); jest.spyOn(axios, 'request').mockReturnValue();
emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => { emojiMenu.addAward(dummyVotesBlock(), dummyAwardUrl, dummyEmoji, false, () => {
expect(axios.request).not.toHaveBeenCalled(); expect(axios.request).not.toHaveBeenCalled();
...@@ -67,7 +67,7 @@ describe('EmojiMenu', () => { ...@@ -67,7 +67,7 @@ describe('EmojiMenu', () => {
describe('bindEvents', () => { describe('bindEvents', () => {
beforeEach(() => { beforeEach(() => {
spyOn(emojiMenu, 'registerEventListener').and.stub(); jest.spyOn(emojiMenu, 'registerEventListener').mockReturnValue();
}); });
it('binds event listeners to custom toggle button', () => { it('binds event listeners to custom toggle button', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment