Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from janoist1/master
Browse files Browse the repository at this point in the history
Add image fallback support + using prop-types
  • Loading branch information
mikefey authored Aug 7, 2017
2 parents 8985e4d + 21ea8d2 commit 0f2ddfb
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 29 deletions.
29 changes: 29 additions & 0 deletions __test__/responsive-image-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,32 @@ test('ResponsiveImage component: Should add style to a background image',
ReactDOM.unmountComponentAtNode(document);
assert.end();
});


test('ResponsiveImage component: Should render a fallback image', (assert) => {
const resourceTimeout = 100;
const component = ReactTestUtils.renderIntoDocument(
<ResponsiveImage>
<ResponsiveImageSize
default
minWidth={0}
path={imageData.initialUrl}
/>
<ResponsiveImageSize
minWidth={1}
path={'not-valid'}
fallbackImage={imageData.initialUrl}
/>
</ResponsiveImage>
);

setTimeout(() => {
const node = ReactDOM.findDOMNode(component).firstChild.firstChild;
const nodeSrc = node.getAttribute('src');

assert.equal(nodeSrc, imageData.initialUrl);

ReactDOM.unmountComponentAtNode(document);
assert.end();
}, resourceTimeout);
});
Loading

0 comments on commit 0f2ddfb

Please sign in to comment.