debian-mirror-gitlab/spec/frontend/notes/components/note_attachment_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1 KiB
JavaScript
Raw Normal View History

2020-03-13 15:44:24 +05:30
import { shallowMount } from '@vue/test-utils';
import NoteAttachment from '~/notes/components/note_attachment.vue';
describe('Issue note attachment', () => {
let wrapper;
2022-08-27 11:52:29 +05:30
const findImage = () => wrapper.findComponent({ ref: 'attachmentImage' });
const findUrl = () => wrapper.findComponent({ ref: 'attachmentUrl' });
2020-03-13 15:44:24 +05:30
2021-03-08 18:12:59 +05:30
const createComponent = (attachment) => {
2020-03-13 15:44:24 +05:30
wrapper = shallowMount(NoteAttachment, {
propsData: {
attachment,
2018-03-17 18:26:18 +05:30
},
2020-03-13 15:44:24 +05:30
});
};
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);
});
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
it('does not render image and url if attachment object is empty', () => {
createComponent({});
2018-03-17 18:26:18 +05:30
2020-03-13 15:44:24 +05:30
expect(findImage().exists()).toBe(false);
expect(findUrl().exists()).toBe(false);
2018-03-17 18:26:18 +05:30
});
});