Skip to content

Commit

Permalink
test(SocialButton): complete GitHub icon testing
Browse files Browse the repository at this point in the history
close #64
  • Loading branch information
sabertazimi committed Aug 4, 2021
1 parent cf1f3b4 commit 0acf22d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
28 changes: 25 additions & 3 deletions src/components/SocialButton/SocialButton.test.tsx
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/');
});
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Header renders correctly 1`] = `
exports[`SocialButton render GitHub correctly (snapshot) 1`] = `
<a
className="ant-btn ant-btn-link ant-btn-lg ant-btn-icon-only text-center text-light rounded-none "
href="https://github.com/"
onClick={[Function]}
role="link"
style={
Object {
"backgroundColor": undefined,
"backgroundColor": "",
}
}
>
Expand Down

0 comments on commit 0acf22d

Please sign in to comment.