Skip to content

Commit

Permalink
test: add fallback test case
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Nov 19, 2024
1 parent b0b8e3e commit 0373f68
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/image/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ describe('Image', () => {
expect(onError).toBeCalledTimes(0);
});

it(': fallback', async () => {
const onError = vi.fn();
const wrapper = mount(() => <Image src={FAIL_IMAGE} fallback={IMAGE} onError={onError} />);
await nextTick();
const $image = wrapper.find(`.${name}__img`);
// 手动触发 图片加载失败的回调函数
await $image.trigger('error');
expect($image.attributes('src')).toBe(IMAGE);
});

it(': onError', async () => {
const onError = vi.fn();
const slots = {
Expand Down

0 comments on commit 0373f68

Please sign in to comment.