2020-01-22 07:08:40 -05:00
|
|
|
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,
|
2017-08-16 14:23:59 -04:00
|
|
|
},
|
2020-01-22 07:08:40 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2017-08-16 14:23:59 -04:00
|
|
|
|
2020-01-22 07:08:40 -05:00
|
|
|
it('does not render image and url if attachment object is empty', () => {
|
|
|
|
createComponent({});
|
2017-08-16 14:23:59 -04:00
|
|
|
|
2020-01-22 07:08:40 -05:00
|
|
|
expect(findImage().exists()).toBe(false);
|
|
|
|
expect(findUrl().exists()).toBe(false);
|
2017-08-16 14:23:59 -04:00
|
|
|
});
|
|
|
|
});
|