-
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.
- Loading branch information
Showing
9 changed files
with
487 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
52 changes: 52 additions & 0 deletions
52
client/src/tests/modules/teams/components/InviteMembers.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,52 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { InviteMember } from '../../../../modules/Teams/components/InviteMembers'; | ||
import { props, emptyProps } from '../teamsMockData'; | ||
|
||
describe('<Test Component />', () => { | ||
it('should mount without crashing', () => { | ||
const wrapper = shallow(<InviteMember {...props} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('should mount with empty props', () => { | ||
const wrapper = shallow(<InviteMember {...emptyProps} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('Should respond to an onChange event of search input', () => { | ||
const wrapper = shallow(<InviteMember {...props} />); | ||
wrapper.find('#invite-members').simulate('change', { target: { value: 'kevin' } }); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('Radio button should respond to an onClick event', () => { | ||
const wrapper = shallow(<InviteMember {...props} />); | ||
wrapper.setState({ searchInput: 'kevin' }); | ||
wrapper.find('.select-all').simulate('click'); | ||
expect(wrapper).toMatchSnapshot(); | ||
wrapper.find('.select-some').simulate('click'); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('handleSelected class methods should be called', () => { | ||
const handleSelected = jest.spyOn(InviteMember.prototype, 'handleSelected'); | ||
const wrapper = shallow(<InviteMember {...props} />); | ||
wrapper.instance().handleSelected(); | ||
expect(handleSelected).toHaveBeenCalled(); | ||
}); | ||
|
||
it('inviteMember class methods should be called', () => { | ||
const inviteMember = jest.spyOn(InviteMember.prototype, 'inviteMember'); | ||
const wrapper = shallow(<InviteMember {...props} />); | ||
wrapper.instance().inviteMember({ preventDefault: jest.fn() }); | ||
expect(inviteMember).toHaveBeenCalled(); | ||
}); | ||
|
||
it('isDisabled class methods should be called', () => { | ||
const isDisabled = jest.spyOn(InviteMember.prototype, 'isDisabled'); | ||
const wrapper = shallow(<InviteMember {...props} />); | ||
wrapper.instance().isDisabled(); | ||
expect(isDisabled).toHaveBeenCalled(); | ||
}); | ||
}); |
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 @@ | ||
|
||
export const props = { | ||
searchUser: jest.fn(), | ||
addMember: jest.fn(), | ||
users: [{ | ||
role: 'admin', | ||
email: 'eze.kevin@andela.com', | ||
githubUsername: 'kenware' | ||
}] | ||
}; | ||
|
||
export const emptyProps = { | ||
searchUser: jest.fn(), | ||
addMember: jest.fn() | ||
}; |
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
Oops, something went wrong.