From 432262d3ad996ed03ec8ac72b388d00c9b5fdc38 Mon Sep 17 00:00:00 2001 From: Ryo Matsukawa Date: Mon, 19 Jun 2023 20:14:15 +0900 Subject: [PATCH] feat: Add tests for 'as' prop and 'onLoad' event in Avatar component --- .../react/src/avatar/__tests__/index.test.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/react/src/avatar/__tests__/index.test.tsx b/packages/react/src/avatar/__tests__/index.test.tsx index 0c94358d89..2361a06259 100644 --- a/packages/react/src/avatar/__tests__/index.test.tsx +++ b/packages/react/src/avatar/__tests__/index.test.tsx @@ -116,4 +116,21 @@ describe("Avatar", () => { expect(imgRef.current).not.toBeNull(); expect(() => wrapper.unmount()).not.toThrow(); }); + + it("should apply button styles when 'as' prop is 'button'", () => { + const wrapper = mount(); + + expect(wrapper.html()).toMatchSnapshot(); + expect(() => wrapper.unmount()).not.toThrow(); + }); + + it("should handle the onLoad event", () => { + const onLoad = jest.fn(); + const wrapper = mount( + , + ); + + wrapper.find("img").simulate("load"); + expect(onLoad).toHaveBeenCalled(); + }); });