Skip to content

Commit

Permalink
Merge a0e7320 into 58ec0e6
Browse files Browse the repository at this point in the history
  • Loading branch information
huangkairan authored Feb 5, 2021
2 parents 58ec0e6 + a0e7320 commit 53c192e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ const ImageInternal: CompoundedComponent<ImageProps> = ({
// Keep order end

React.useEffect(() => {
if (isError) {
setStatus('normal');
}
if (isCustomPlaceholder) {
setStatus('loading');
}
Expand Down
15 changes: 15 additions & 0 deletions tests/fallback.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,19 @@ describe('Fallback', () => {

expect(onErrorMock).toHaveBeenCalledTimes(1);
});

it('should change image, not error', () => {
const wrapper = mount(<Image width={200} src="error" fallback='https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' />);
act(() => {
wrapper.setProps({
src: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ',
});
jest.runAllTimers();
wrapper.update();
});
expect(wrapper.find('.rc-image-img').prop('src')).toBe(
'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ',
);
});

});

0 comments on commit 53c192e

Please sign in to comment.