Skip to content

Commit

Permalink
Fix: Avatar Icon tests & documentation (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricevladimir authored Jan 22, 2024
1 parent fbde791 commit b6fbe0d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added

- Implement `InputDate` and `Avatar` components
- Add `AvatarIcon` documentation and tests

## [1.0.8] - 2024-01-17

Expand Down
17 changes: 17 additions & 0 deletions src/components/avatars/avatarIcon/avatarIcon.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from '@testing-library/react';

import { IconType } from '../../icon';
import { AvatarIcon, type IAvatarIconProps } from './avatarIcon';

describe('<AvatarIcon /> component', () => {
const createTestComponent = (props?: Partial<IAvatarIconProps>) => {
const completeProps: IAvatarIconProps = { icon: IconType.ADD, ...props };

return <AvatarIcon {...completeProps} />;
};

it('renders the specified icon', () => {
render(createTestComponent({ icon: IconType.APP_FINANCE }));
expect(screen.getByTestId(IconType.APP_FINANCE)).toBeInTheDocument();
});
});
18 changes: 16 additions & 2 deletions src/components/avatars/avatarIcon/avatarIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ type AvatarIconSize = 'sm' | 'md' | 'lg';
type AvatarIconVariant = 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'critical';

export interface IAvatarIconProps extends HTMLAttributes<HTMLDivElement> {
/**
* The icon type
*/
icon: IconType;
/**
* Responsive size attribute for the avatar.
*/
responsiveSize?: ResponsiveAttribute<AvatarIconSize>;
/**
* The size of the avatar icon.
* @default sm
*/
size?: AvatarIconSize;
/**
* The variant of the avatar.
* @default neutral
*/
variant?: AvatarIconVariant;
responsiveSize?: ResponsiveAttribute<AvatarIconSize>;
icon: IconType;
}

const avatarVariantToIconClassNames: Record<AvatarIconVariant, string> = {
Expand Down

0 comments on commit b6fbe0d

Please sign in to comment.