Commit b1653499 authored by Tom Quirk's avatar Tom Quirk

Add test for design item using imageV432x230

Test that, when imageV432x230 is provided,
it is used.

Also slightly reorganises the tests for better readability
parent 60d1d770
......@@ -17,6 +17,7 @@ const DESIGN_VERSION_EVENT = {
describe('Design management list item component', () => {
let wrapper;
function createComponent({
notesCount = 0,
event = DESIGN_VERSION_EVENT.NO_CHANGE,
......@@ -48,17 +49,39 @@ describe('Design management list item component', () => {
wrapper.destroy();
});
it('renders an image when it appears in view', () => {
createComponent();
const image = wrapper.find('img');
describe('when item is not in view', () => {
it('image is not rendered', () => {
createComponent();
const image = wrapper.find('img');
expect(image.attributes('src')).toBe('');
});
});
expect(image.attributes('src')).toBe('');
describe('when item appears in view', () => {
beforeEach(() => {
createComponent();
wrapper.find(GlIntersectionObserver).vm.$emit('appear');
wrapper.find(GlIntersectionObserver).vm.$emit('appear');
return wrapper.vm.$nextTick();
});
return wrapper.vm.$nextTick().then(() => {
it('renders an image', () => {
const image = wrapper.find('img');
expect(image.attributes('src')).toBe('http://via.placeholder.com/300');
});
describe('when imageV432x230 and image provided', () => {
it('renders imageV432x230 image', () => {
const mockSrc = 'mock-imageV432x230-url';
wrapper.setProps({ imageV432x230: mockSrc });
return wrapper.vm.$nextTick().then(() => {
const image = wrapper.find('img');
expect(image.attributes('src')).toBe(mockSrc);
});
});
});
});
describe('with notes', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment