kalykun
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
0 deletions
-
components/avatar/__tests__/Avatar.test.js
-
components/avatar/avatar.tsx
|
|
@ -214,4 +214,11 @@ describe('Avatar Render', () => { |
|
|
|
expect(wrapper.html().includes('crossorigin')).toEqual(false); |
|
|
|
expect(wrapper.find('img').prop('crossOrigin')).toEqual(undefined); |
|
|
|
}); |
|
|
|
|
|
|
|
it('clickable', async () => { |
|
|
|
const onClick = jest.fn(); |
|
|
|
const { container } = render(<Avatar onClick={onClick}>TestString</Avatar>); |
|
|
|
fireEvent.click(container.querySelector('.ant-avatar-string')); |
|
|
|
expect(onClick).toHaveBeenCalled(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
@ -32,6 +32,7 @@ export interface AvatarProps { |
|
|
|
children?: React.ReactNode; |
|
|
|
alt?: string; |
|
|
|
crossOrigin?: '' | 'anonymous' | 'use-credentials'; |
|
|
|
onClick?: (e?: React.MouseEvent<HTMLElement>) => void; |
|
|
|
/* callback when img load error */ |
|
|
|
/* return false to prevent Avatar show default fallback behavior, then you can do fallback by your self */ |
|
|
|
onError?: () => boolean; |
|
|
|