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

46 lines
1.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;
const findImage = () => wrapper.find({ ref: 'attachmentImage' });
const findUrl = () => wrapper.find({ ref: 'attachmentUrl' });
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
});
};
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);
});
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
});
});