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

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-03-09 13:42:32 +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' });
const createComponent = attachment => {
wrapper = shallowMount(NoteAttachment, {
propsData: {
attachment,
2018-03-17 18:26:18 +05:30
},
2020-03-09 13:42:32 +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-09 13:42:32 +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-09 13:42:32 +05:30
expect(findImage().exists()).toBe(false);
expect(findUrl().exists()).toBe(false);
2018-03-17 18:26:18 +05:30
});
});