-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: auth method icon component (#1195)
- Loading branch information
Showing
5 changed files
with
405 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
304
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.
Oops, something went wrong.
Oops, something went wrong.