Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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