Skip to content

Commit

Permalink
feat: Add tests for 'as' prop and 'onLoad' event in Avatar component
Browse files Browse the repository at this point in the history
  • Loading branch information
ryo-manba committed Jun 19, 2023
1 parent 23c4cc1 commit 432262d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/react/src/avatar/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<Avatar as="button" />);

expect(wrapper.html()).toMatchSnapshot();
expect(() => wrapper.unmount()).not.toThrow();
});

it("should handle the onLoad event", () => {
const onLoad = jest.fn();
const wrapper = mount(
<Avatar src="https://i.pravatar.cc/300?u=a042581f4e29026705d" onLoad={onLoad} />,
);

wrapper.find("img").simulate("load");
expect(onLoad).toHaveBeenCalled();
});
});

0 comments on commit 432262d

Please sign in to comment.