debian-mirror-gitlab/spec/frontend/emoji/components/emoji_group_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-04-17 20:07:23 +05:30
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import EmojiGroup from '~/emoji/components/emoji_group.vue';
Vue.config.ignoredElements = ['gl-emoji'];
let wrapper;
function factory(propsData = {}) {
wrapper = extendedWrapper(
shallowMount(EmojiGroup, {
propsData,
}),
);
}
describe('Emoji group component', () => {
afterEach(() => {
wrapper.destroy();
});
it('does not render any buttons', () => {
factory({
emojis: [],
renderGroup: false,
clickEmoji: jest.fn(),
});
expect(wrapper.findByTestId('emoji-button').exists()).toBe(false);
});
it('renders emojis', () => {
factory({
emojis: ['thumbsup', 'thumbsdown'],
renderGroup: true,
clickEmoji: jest.fn(),
});
expect(wrapper.findAllByTestId('emoji-button').exists()).toBe(true);
expect(wrapper.findAllByTestId('emoji-button').length).toBe(2);
});
it('calls clickEmoji', () => {
const clickEmoji = jest.fn();
factory({
emojis: ['thumbsup', 'thumbsdown'],
renderGroup: true,
clickEmoji,
});
wrapper.findByTestId('emoji-button').trigger('click');
expect(clickEmoji).toHaveBeenCalledWith('thumbsup');
});
});