Skip to content

Commit

Permalink
test: mock trigger image error event (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaodahong authored Feb 7, 2021
1 parent e069a77 commit c08c09c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/fallback.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ describe('Fallback', () => {
});

it('should change image, not error', () => {
const wrapper = mount(<Image width={200} src="error" fallback='https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png' />);
const wrapper = mount(
<Image
width={200}
src="error"
fallback="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
/>,
);
act(() => {
wrapper.find('.rc-image-img').simulate('error');
wrapper.setProps({
src: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ',
src:
'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ',
});
jest.runAllTimers();
wrapper.update();
Expand All @@ -72,5 +80,4 @@ describe('Fallback', () => {
'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*NZuwQp_vcIQAAAAAAAAAAABkARQnAQ',
);
});

});

1 comment on commit c08c09c

@vercel
Copy link

@vercel vercel bot commented on c08c09c Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.