-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from kaushiknishchay/test-case
Test cases for Components
- Loading branch information
Showing
7 changed files
with
90 additions
and
8 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
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,15 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Profile from '../Profile'; | ||
|
||
describe('Profile Component', () => { | ||
const profileData = { | ||
login: 'username', | ||
bio: 'this is my bio', | ||
avatar_url: 'https://avatars1.githubusercontent.com/u/15786884?v=4', | ||
}; | ||
it('should Render Profile Info', () => { | ||
const wrapper = shallow(<Profile data={profileData} />); | ||
expect(wrapper.find('.mt-0').contains(profileData.login)).toBe(true); | ||
}); | ||
}); |
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,21 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import RepoList from '../RepoList'; | ||
|
||
describe('RepoList Component', () => { | ||
const repos = [{ | ||
id: 35507603, | ||
name: 'aerosolve', | ||
}, | ||
{ | ||
id: 88910481, | ||
name: 'airbnb-spark-thrift', | ||
}]; | ||
|
||
it('should Render 2 repo items', () => { | ||
const wrapper = shallow(<RepoList data={repos} />); | ||
|
||
// should show 2 repo items in list | ||
expect(wrapper.find('.list-group-item').length).toBe(2); | ||
}); | ||
}); |
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,34 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Header from '../../components/Header'; | ||
|
||
describe('Header Container Component', () => { | ||
it('should show Sign In Button', () => { | ||
const onClick = jest.fn(); | ||
|
||
const wrapper = shallow(<Header isSignIn={false} onClick={onClick} />); | ||
|
||
const btn = wrapper.find('button'); | ||
|
||
expect(btn.text()).toBe('Sign In'); | ||
|
||
btn.simulate('click', 'text'); | ||
|
||
expect(onClick.mock.calls[0][0]).toBe('text'); | ||
|
||
expect(onClick).toHaveBeenCalledTimes(1); | ||
}); | ||
it('should show Sign Out Button', () => { | ||
const onClick = jest.fn(); | ||
|
||
const wrapper = shallow(<Header isSignIn onClick={onClick} />); | ||
|
||
const btn = wrapper.find('button'); | ||
|
||
expect(btn.text()).toBe('Sign Out'); | ||
|
||
btn.simulate('click', 'text'); | ||
|
||
expect(onClick.mock.calls[0][0]).toBe('text'); | ||
}); | ||
}); |
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
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
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 +1,5 @@ | ||
import 'jest-localstorage-mock'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import * as Enzyme from 'enzyme'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); |