Skip to content

Commit

Permalink
add button test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kachulio1 committed Jan 10, 2019
1 parent d6f3890 commit abd1afa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
File renamed without changes.
33 changes: 33 additions & 0 deletions src/tests/common/Button.test.js
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);
});
});

0 comments on commit abd1afa

Please sign in to comment.