blob: d85cd46c1c3989d58fc86ba2bc4849cb6c3afbbb (
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
51
52
|
import { shallowMount } from '@vue/test-utils';
import ReplyButton from '~/notes/components/note_actions/reply_button.vue';
import WorkItemNoteActions from '~/work_items/components/notes/work_item_note_actions.vue';
describe('Work Item Note Actions', () => {
let wrapper;
const findReplyButton = () => wrapper.findComponent(ReplyButton);
const findEditButton = () => wrapper.find('[data-testid="edit-work-item-note"]');
const createComponent = ({ showReply = true, showEdit = true } = {}) => {
wrapper = shallowMount(WorkItemNoteActions, {
propsData: {
showReply,
showEdit,
},
});
};
describe('Default', () => {
it('Should show the reply button by default', () => {
createComponent();
expect(findReplyButton().exists()).toBe(true);
});
});
describe('When the reply button needs to be hidden', () => {
it('Should show the reply button by default', () => {
createComponent({ showReply: false });
expect(findReplyButton().exists()).toBe(false);
});
});
it('shows edit button when `showEdit` prop is true', () => {
createComponent();
expect(findEditButton().exists()).toBe(true);
});
it('does not show edit button when `showEdit` prop is false', () => {
createComponent({ showEdit: false });
expect(findEditButton().exists()).toBe(false);
});
it('emits `startEditing` event when edit button is clicked', () => {
createComponent();
findEditButton().vm.$emit('click');
expect(wrapper.emitted('startEditing')).toEqual([[]]);
});
});
|