diff --git a/src/components/Image.js b/src/components/Image.js index a144828..53620c9 100644 --- a/src/components/Image.js +++ b/src/components/Image.js @@ -21,7 +21,7 @@ export default { attrs: { ...data.attrs, src: url, - alt, + alt: alt || "", copyright } }) diff --git a/test/components-PrismicImage.test.js b/test/components-PrismicImage.test.js index 6409f87..870cd7a 100644 --- a/test/components-PrismicImage.test.js +++ b/test/components-PrismicImage.test.js @@ -17,11 +17,19 @@ test("renders image field", (t) => { t.snapshot(wrapper.html()); }); +test("renders image field with an accessible default alt value", (t) => { + const wrapper = mount(PrismicImage, { + propsData: { field: { ...mock.value.image({ seed: 2 }), alt: null } }, + }); + + t.snapshot(wrapper.html()); +}); + test("renders partial image field", (t) => { const wrapper = mount(PrismicImage, { propsData: { field: { - ...mock.value.image({ seed: 2 }), + ...mock.value.image({ seed: 3 }), url: null, alt: null, copyright: null, @@ -71,13 +79,13 @@ test("reacts to changes properly", async (t) => { }); const wrapper = mount(PrismicImageProxy, { - propsData: { field: mock.value.image({ seed: 5 }) }, + propsData: { field: mock.value.image({ seed: 4 }) }, }); const firstRender = wrapper.html(); await wrapper.setProps({ - field: mock.value.image({ seed: 6 }), + field: mock.value.image({ seed: 5 }), }); const secondRender = wrapper.html(); diff --git a/test/snapshots/components-PrismicImage.test.js.md b/test/snapshots/components-PrismicImage.test.js.md index 49dda55..de75d76 100644 --- a/test/snapshots/components-PrismicImage.test.js.md +++ b/test/snapshots/components-PrismicImage.test.js.md @@ -10,14 +10,20 @@ Generated by [AVA](https://avajs.dev). 'Repellat ratione ut sunt qui.' +## renders image field with an accessible default alt value + +> Snapshot 1 + + '' + ## renders partial image field > Snapshot 1 - '' + '' ## reacts to changes properly > Snapshot 1 - 'Est quam provident suscipit atque fuga dolorem.' + 'Quia commodi sint reiciendis corrupti sunt laborum qui voluptas.' diff --git a/test/snapshots/components-PrismicImage.test.js.snap b/test/snapshots/components-PrismicImage.test.js.snap index e68fcc4..679292a 100644 Binary files a/test/snapshots/components-PrismicImage.test.js.snap and b/test/snapshots/components-PrismicImage.test.js.snap differ