blob: 24632f8e4279a49d631a81579140a791c8e0c814 (
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
|
import { shallowMount } from '@vue/test-utils';
import NoteAttachment from '~/notes/components/note_attachment.vue';
describe('Issue note attachment', () => {
let wrapper;
const findImage = () => wrapper.findComponent({ ref: 'attachmentImage' });
const findUrl = () => wrapper.findComponent({ ref: 'attachmentUrl' });
const createComponent = (attachment) => {
wrapper = shallowMount(NoteAttachment, {
propsData: {
attachment,
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('renders attachment image if it is passed in attachment prop', () => {
createComponent({
image: 'test-image',
});
expect(findImage().exists()).toBe(true);
});
it('renders attachment url if it is passed in attachment prop', () => {
createComponent({
url: 'test-url',
});
expect(findUrl().exists()).toBe(true);
});
it('does not render image and url if attachment object is empty', () => {
createComponent({});
expect(findImage().exists()).toBe(false);
expect(findUrl().exists()).toBe(false);
});
});
|