-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- write tests for Footer component - write tests for Navbar component - write tests for Modal components - write tests for Spinner component - write tests for Preloader component [Starts #161117046]
- Loading branch information
Showing
9 changed files
with
154 additions
and
4 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
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,11 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Footer from '../../../../modules/common/Footer'; | ||
|
||
describe('<Footer />', () => { | ||
it('should mount without crashing', () => { | ||
const wrapper = shallow(<Footer />); | ||
expect(wrapper.find('.col').props().children[0]).toBe('© '); | ||
expect(wrapper.find('.col').props().children[1]).toBe(2018); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
client/src/tests/modules/common/Modals/AddIntegration.test.jsx
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,14 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import AddIntegration from '../../../../modules/common/Modals/AddIntegration'; | ||
|
||
describe('<AddIntegration />', () => { | ||
it('should mount without crashing', () => { | ||
const wrapper = shallow(<AddIntegration />); | ||
expect(wrapper.find('p').get(0).props.children).toBe('Select an integration to add'); | ||
expect(wrapper.find('p').get(1).props.children).toBe('Github Repo'); | ||
expect(wrapper.find('p').get(2).props.children).toBe('Pivotal Tracker'); | ||
expect(wrapper.find('p').get(3).props.children).toBe('Slack Channel (private)'); | ||
expect(wrapper.find('p').get(4).props.children).toBe('Slack Channel (public)'); | ||
}); | ||
}); |
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,14 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import AddMember from '../../../../modules/common/Modals/AddMember'; | ||
|
||
describe('<AddMember />', () => { | ||
it('should mount without crashing', () => { | ||
const wrapper = shallow(<AddMember />); | ||
expect(wrapper.find('h4').props().children).toBe('Add member'); | ||
expect(wrapper.find('i').props().children).toBe('account_circle'); | ||
expect(wrapper.find('label').props().children).toBe('Find member'); | ||
expect(wrapper.find('a').get(0).props.children).toBe('Back'); | ||
expect(wrapper.find('a').get(1).props.children).toBe('Add'); | ||
}); | ||
}); |
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,73 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Navbar } from '../../../../modules/common/Navbar'; | ||
|
||
describe('<Navbar />', () => { | ||
let wrapper; | ||
const onClick = jest.fn(); | ||
const auth = { | ||
name: 'Taps Client' | ||
}; | ||
const requestsReducer = { | ||
error: '', | ||
success: '', | ||
}; | ||
document.getElementById = jest.fn(() => ({ | ||
focus: jest.fn() | ||
})); | ||
beforeEach(() => { | ||
wrapper = shallow(<Navbar | ||
switchContent={onClick} | ||
showTabs | ||
showIcon | ||
auth={auth} | ||
handleSubmit={onClick} | ||
signOut={onClick} | ||
id="search" | ||
requestsReducer={requestsReducer} | ||
/>); | ||
}); | ||
it('should mount without crashing', () => { | ||
expect(wrapper.length).toBe(1); | ||
}); | ||
it('should click projects', () => { | ||
wrapper.find('.projects').simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should click members', () => { | ||
wrapper.find('.members').simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should click account', () => { | ||
wrapper.find('.account').simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should show search bar', () => { | ||
wrapper.find('#showSearchBar').simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should show search bar', () => { | ||
wrapper.find('#showSearchBar2').simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should show search bar', () => { | ||
wrapper.find('#showSearchBar3').simulate('click'); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should test handleSearch method', () => { | ||
wrapper.instance().handleSearch({ preventDefault: jest.fn() }); | ||
expect(wrapper.instance().state.showSearchBar).toBe(false); | ||
}); | ||
it('should test signOut method', () => { | ||
wrapper.instance().signOut({ preventDefault: jest.fn() }); | ||
expect(onClick).toHaveBeenCalled(); | ||
}); | ||
it('should test toggleState', () => { | ||
jest.useFakeTimers(); | ||
wrapper.instance().toggleState('showSearchBar'); | ||
setTimeout(() => { | ||
document.getElementById(); | ||
}, 100); | ||
jest.runAllTimers(); | ||
}); | ||
}); |
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,19 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Preloader, mapStateToProps } from '../../../../modules/common/Preloader'; | ||
|
||
const isLoading = { | ||
isLoading: true | ||
}; | ||
|
||
describe('<Preloader />', () => { | ||
it('should mount without crashing', () => { | ||
const wrapper = shallow(<Preloader isLoading={isLoading} />); | ||
expect(wrapper.length).toBe(1); | ||
expect(wrapper.exists('.indeterminate')).toEqual(true); | ||
}); | ||
it('should test mapStateToProps', () => { | ||
const newState = mapStateToProps(isLoading); | ||
expect(newState.isLoading).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,12 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Spinner from '../../../../modules/common/Spinner/Spinner'; | ||
|
||
|
||
describe('<Spinner />', () => { | ||
it('should mount without crashing', () => { | ||
const wrapper = shallow(<Spinner />); | ||
expect(wrapper.length).toBe(1); | ||
expect(wrapper.exists('.spinner')).toEqual(true); | ||
}); | ||
}); |