Skip to content

Commit

Permalink
refactor: auth method icon component (#1195)
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 7, 2024
1 parent ce7f2b5 commit 7016c21
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 58 deletions.
31 changes: 31 additions & 0 deletions src/components/icons/AuthMethodIcon.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { render } from '@testing-library/react';
import { AuthMethodIcon, type IAuthMethodIcon } from './AuthMethodIcon';

describe('components/icons/AuthMethodIcon.tsx', () => {
it('should render GitHub App icon', () => {
const props: IAuthMethodIcon = {
type: 'GitHub App',
size: 16,
};
const tree = render(<AuthMethodIcon {...props} />);
expect(tree).toMatchSnapshot();
});

it('should render Personal Access Token icon', () => {
const props: IAuthMethodIcon = {
type: 'Personal Access Token',
size: 16,
};
const tree = render(<AuthMethodIcon {...props} />);
expect(tree).toMatchSnapshot();
});

it('should render OAuth App icon', () => {
const props: IAuthMethodIcon = {
type: 'OAuth App',
size: 16,
};
const tree = render(<AuthMethodIcon {...props} />);
expect(tree).toMatchSnapshot();
});
});
20 changes: 20 additions & 0 deletions src/components/icons/AuthMethodIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AppsIcon, KeyIcon, PersonIcon } from '@primer/octicons-react';
import type { FC } from 'react';
import type { AuthMethod } from '../../utils/auth/types';

export interface IAuthMethodIcon {
type: AuthMethod;
size: number;
}

export const AuthMethodIcon: FC<IAuthMethodIcon> = (props: IAuthMethodIcon) => {
return (
<span aria-label={props.type} className="mr-1">
{props.type === 'GitHub App' ? <AppsIcon size={props.size} /> : null}
{props.type === 'Personal Access Token' ? (
<KeyIcon size={props.size} />
) : null}
{props.type === 'OAuth App' ? <PersonIcon size={props.size} /> : null}
</span>
);
};
304 changes: 304 additions & 0 deletions src/components/icons/__snapshots__/AuthMethodIcon.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7016c21

Please sign in to comment.