Skip to content

Commit

Permalink
fix(Image): use correct img tag load and error event name
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Oct 13, 2022
1 parent 2e9a3dc commit aad8a37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/image/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ describe('Image', () => {
await nextTick();
const $image = wrapper.find(`.${name}__img`);
expect(wrapper.find(`.${name}__status`).exists()).toBeTruthy();
// 触发 IntersectionObserver , 但图片加载完成不会触发 Load 回调,
// 触发 IntersectionObserver , 但图片加载完成不会触发 load 回调,
$image.trigger('resize');
await nextTick();
expect($image.attributes('src')).toBe(IMAGE);
// 手动触发 图片加载完成的回调函数
await $image.trigger('Load');
await $image.trigger('load');
expect(wrapper.element).toMatchSnapshot();
expect(wrapper.find(`.${name}__status`).exists()).toBeFalsy();
});
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('Image', () => {
await nextTick();
const $image = wrapper.find(`.${name}__img`);
// 手动触发 图片加载失败的回调函数
await $image.trigger('Error');
await $image.trigger('error');
expect(wrapper.find(`.${name}__status`).exists()).toBeTruthy();
// src = '',不会触发 error
expect(onError).toBeCalledTimes(0);
Expand All @@ -123,7 +123,7 @@ describe('Image', () => {
await nextTick();
const $image = wrapper.find(`.${name}__img`);
// 手动触发 图片加载失败的回调函数
await $image.trigger('Error');
await $image.trigger('error');
const status = wrapper.find(`.${name}__status`);
expect(status.exists()).toBeTruthy();
expect(status.text()).toBe('加载失败');
Expand All @@ -137,7 +137,7 @@ describe('Image', () => {
const $image = wrapper.find(`.${name}__img`);
expect($image.attributes('src')).toBe(IMAGE);
// 手动触发 图片加载完成的回调函数
await $image.trigger('Load');
await $image.trigger('load');
expect(onLoad).toBeCalledTimes(1);
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/image/image.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
:style="imageStyles"
:src="realSrc"
:alt="alt"
@Load="handleImgLoadCompleted"
@Error="handleImgLoadError"
@load="handleImgLoadCompleted"
@error="handleImgLoadError"
/>
</div>
</template>
Expand Down

0 comments on commit aad8a37

Please sign in to comment.