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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
import { shallowMount } from '@vue/test-utils';
import { GlLink, GlModal } from '@gitlab/ui';
import { mockTracking, unmockTracking, triggerEvent } from 'helpers/tracking_helper';
import { stubComponent } from 'helpers/stub_component';
import InviteMemberModal from '~/invite_member/components/invite_member_modal.vue';
const memberPath = 'member_path';
const GlEmoji = { template: '<img />' };
const createComponent = () => {
return shallowMount(InviteMemberModal, {
provide: {
membersPath: memberPath,
},
stubs: {
GlEmoji,
GlModal: stubComponent(GlModal, {
template: '<div><slot name="modal-title"></slot><slot></slot></div>',
}),
},
});
};
describe('InviteMemberModal', () => {
let wrapper;
beforeEach(() => {
wrapper = createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const findLink = () => wrapper.find(GlLink);
describe('rendering the modal', () => {
it('renders the modal with the correct title', () => {
expect(wrapper.text()).toContain("Oops, this feature isn't ready yet");
});
describe('rendering the see who link', () => {
it('renders the correct link', () => {
expect(findLink().attributes('href')).toBe(memberPath);
});
});
});
describe('tracking', () => {
let trackingSpy;
afterEach(() => {
unmockTracking();
});
it('send an event when go to pipelines is clicked', () => {
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
triggerEvent(findLink().element);
expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_who_can_invite_link', {
label: 'invite_members_message',
});
});
});
});
|