blob: 6861059f19cc29310ba8b3739f52e803bf0f1ddc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import { GlIntersectionObserver } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import Category from '~/emoji/components/category.vue';
import EmojiGroup from '~/emoji/components/emoji_group.vue';
let wrapper;
function factory(propsData = {}) {
wrapper = shallowMount(Category, { propsData });
}
const triggerGlIntersectionObserver = () => {
wrapper.findComponent(GlIntersectionObserver).vm.$emit('appear');
return nextTick();
};
describe('Emoji category component', () => {
afterEach(() => {
wrapper.destroy();
});
beforeEach(() => {
factory({
category: 'Activity',
emojis: [['thumbsup'], ['thumbsdown']],
});
});
it('renders emoji groups', () => {
expect(wrapper.findAllComponents(EmojiGroup).length).toBe(2);
});
it('renders group', async () => {
await triggerGlIntersectionObserver();
expect(wrapper.findComponent(EmojiGroup).attributes('rendergroup')).toBe('true');
});
it('renders group on appear', async () => {
await triggerGlIntersectionObserver();
expect(wrapper.findComponent(EmojiGroup).attributes('rendergroup')).toBe('true');
});
it('emits appear event on appear', async () => {
await triggerGlIntersectionObserver();
expect(wrapper.emitted().appear[0]).toEqual(['Activity']);
});
});
|