Skip to content

Commit

Permalink
test(GithubCard): add snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sabertazimi committed Aug 5, 2021
1 parent c19aa75 commit 061c6e1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/components/GithubCard/GithubCard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React from 'react';
import renderer from 'react-test-renderer';
import { render } from '@testing-library/react';
import GithubCard from './GithubCard';

describe('GithubCard', () => {
const github = {
profile: {
username: 'sabertazimi',
avatar: 'https://avatars.githubusercontent.com/u/12670482?v=4',
bio: 'CS',
location: 'Wuhan',
url: 'https://github.com/sabertazimi',
followers: 42,
followersUrl: 'https://github.com/sabertazimi/followers',
following: 185,
followingUrl: 'https://github.com/sabertazimi/following',
createDate: 'Sat May 30 2015',
},
repos: [
{
name: 'hust-lab',
stars: 22,
language: 'C',
repoUrl: 'https://github.com/sabertazimi/hust-lab',
},
{
name: 'awesome-notes',
stars: 22,
language: 'JavaScript',
repoUrl: 'https://github.com/sabertazimi/awesome-notes',
},
{
name: 'dragon-zsh-theme',
stars: 11,
language: 'Zsh',
repoUrl: 'https://github.com/sabertazimi/dragon-zsh-theme',
},
],
};

test('should render correctly (snapshot)', () => {
const tree = renderer.create(<GithubCard github={github} />).toJSON();
expect(tree).toMatchSnapshot();
});
});

0 comments on commit 061c6e1

Please sign in to comment.