-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(SocialButton): complete GitHub icon testing
close #64
- Loading branch information
1 parent
cf1f3b4
commit 0acf22d
Showing
2 changed files
with
28 additions
and
5 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 |
---|---|---|
@@ -1,13 +1,35 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
import { render } from '@testing-library/react'; | ||
import SocialButton from './SocialButton'; | ||
|
||
describe('Header', () => { | ||
it('renders correctly', () => { | ||
describe('SocialButton', () => { | ||
test('render GitHub correctly (snapshot)', () => { | ||
const tree = renderer | ||
.create(<SocialButton type="github" url="https://github.com/" />) | ||
.toJSON(); | ||
|
||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
test('render GitHub with correct structure', () => { | ||
const { getByRole } = render( | ||
<SocialButton type="github" url="https://github.com/" /> | ||
); | ||
const link = getByRole('link'); | ||
const icon = getByRole('img'); | ||
|
||
expect(link).toBeInTheDocument(); | ||
expect(icon).toBeInTheDocument(); | ||
expect(link).toContainElement(icon); | ||
}); | ||
|
||
test('render GitHub with correct structure', () => { | ||
const { getByRole } = render( | ||
<SocialButton type="github" url="https://github.com/" /> | ||
); | ||
const link = getByRole('link'); | ||
|
||
expect(link).toHaveAttribute('href', 'https://github.com/'); | ||
}); | ||
}); |
5 changes: 3 additions & 2 deletions
5
src/components/SocialButton/__snapshots__/SocialButton.test.tsx.snap
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