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 { mount } from '@vue/test-utils';
import { GlBadge, GlPopover } from '@gitlab/ui';
import HoverBadge from '~/vue_shared/components/badges/hover_badge.vue';
describe('Hover badge component', () => {
let wrapper;
const findBadge = () => wrapper.findComponent(GlBadge);
const findPopover = () => wrapper.findComponent(GlPopover);
const createWrapper = ({ props = {}, slots } = {}) => {
wrapper = mount(HoverBadge, {
propsData: {
label: 'Label',
title: 'Title',
...props,
},
slots,
});
};
it('passes label to popover', () => {
createWrapper();
expect(findBadge().text()).toBe('Label');
});
it('passes title to popover', () => {
createWrapper();
expect(findPopover().props('title')).toBe('Title');
});
it('renders the default slot', () => {
createWrapper({ slots: { default: '<p>This is an awesome content</p>' } });
expect(findPopover().text()).toContain('This is an awesome content');
});
it('passes default size to badge', () => {
createWrapper();
expect(findBadge().props('size')).toBe('md');
});
it('passes given size to badge', () => {
createWrapper({ props: { size: 'sm' } });
expect(findBadge().props('size')).toBe('sm');
});
});
|