From 0373f6823d6a0f36ff670433deab204c48898b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 19 Nov 2024 22:36:50 +0800 Subject: [PATCH] test: add fallback test case --- src/image/__test__/index.test.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/image/__test__/index.test.jsx b/src/image/__test__/index.test.jsx index 9e60b70e4..41b4a62ea 100644 --- a/src/image/__test__/index.test.jsx +++ b/src/image/__test__/index.test.jsx @@ -114,6 +114,16 @@ describe('Image', () => { expect(onError).toBeCalledTimes(0); }); + it(': fallback', async () => { + const onError = vi.fn(); + const wrapper = mount(() => ); + 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 = {