-
Notifications
You must be signed in to change notification settings - Fork 24
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
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
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,33 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Button from '../../common/Button'; | ||
|
||
describe('<Button />', () => { | ||
const submitHandler = jest.fn(); | ||
const props = { | ||
name: 'stripe-button', | ||
value: 'Update Card Details', | ||
className: 'btn', | ||
onClick: submitHandler, | ||
disabled: false, | ||
}; | ||
|
||
const wrapper = shallow(<Button {...props} />); | ||
|
||
it('should render without crashing', () => { | ||
expect(wrapper.length).toBe(1); | ||
}); | ||
|
||
it('should display the value', () => { | ||
expect(wrapper.find('.btn').text()).toBe('Update Card Details'); | ||
}); | ||
|
||
it('should have type attribute default value as button', () => { | ||
expect(wrapper.props()['type']).toBe('button'); | ||
}); | ||
|
||
it('should call onclick event handler when clicked', () => { | ||
wrapper.simulate('click') | ||
expect(submitHandler).toBeCalledTimes(1); | ||
}); | ||
}); |