Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
huangkairan committed Feb 5, 2021
1 parent 58ec0e6 commit f037fd1
Show file tree
Hide file tree
Showing 2 changed files with 17 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
14 changes: 14 additions & 0 deletions tests/fallback.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,18 @@ 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 f037fd1

Please sign in to comment.