Skip to content

Commit

Permalink
EnlargedImage: Default alt Attribute to Empty String
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanselzer committed Apr 2, 2018
1 parent 377c938 commit 106b31c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/EnlargedImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default class extends React.Component {
isLazyLoaded,
largeImage,
largeImage: {
alt = '',
onLoad = noop,
onError = noop
},
Expand All @@ -194,7 +195,7 @@ export default class extends React.Component {
style: this.containerStyle
}}>
<img { ...{
alt: largeImage.alt,
alt,
className: imageClassName,
src: largeImage.src,
srcSet: largeImage.srcSet,
Expand Down
9 changes: 8 additions & 1 deletion test/enlarged-image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,19 @@ describe('Enlarged Image', () => {
});

it('applies large image alt', () => {
shallowWrapper.setProps({ largeImage: {alt: 'foo'}});

const renderedWrapper = shallowWrapper.render();

expect(renderedWrapper.find('img').attr('alt')).to.equal('foo');
});

it('defaults large image alt to empty string', () => {
const renderedWrapper = shallowWrapper.render();

expect(renderedWrapper.find('img').attr('alt')).to.equal('');
});

it('applies large image src', () => {
const renderedWrapper = shallowWrapper.render();

Expand Down Expand Up @@ -506,7 +514,6 @@ describe('Enlarged Image', () => {
fadeDurationInMs: 0,
isActive: false,
largeImage: {
alt: 'foo',
src: 'bar',
srcSet: 'corge',
width: 12,
Expand Down

0 comments on commit 106b31c

Please sign in to comment.