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
68
69
|
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import resolveDiscussionButton from '~/notes/components/discussion_resolve_button.vue';
const buttonTitle = 'Resolve discussion';
describe('resolveDiscussionButton', () => {
let wrapper;
const factory = (options) => {
wrapper = shallowMount(resolveDiscussionButton, {
...options,
});
};
beforeEach(() => {
factory({
propsData: {
isResolving: false,
buttonTitle,
},
});
});
it('should emit a onClick event on button click', async () => {
const button = wrapper.findComponent(GlButton);
button.vm.$emit('click');
await nextTick();
expect(wrapper.emitted()).toEqual({
onClick: [[]],
});
});
it('should contain the provided button title', () => {
const button = wrapper.findComponent(GlButton);
expect(button.text()).toContain(buttonTitle);
});
it('should show a loading spinner while resolving', () => {
factory({
propsData: {
isResolving: true,
buttonTitle,
},
});
const button = wrapper.findComponent(GlButton);
expect(button.props('loading')).toEqual(true);
});
it('should only show a loading spinner while resolving', async () => {
factory({
propsData: {
isResolving: false,
buttonTitle,
},
});
const button = wrapper.findComponent(GlButton);
await nextTick();
expect(button.props('loading')).toEqual(false);
});
});
|