import React from 'react'; import { mount, shallow } from 'enzyme'; import SocialButton from '.'; describe('', () => { it('renders without error', () => { const wrapper = mount( ); expect(wrapper).toExist(); }); it('not re-render test', () => { // const onClick= () => alert('SocialButton clicked'); const wrapper = shallow().instance(); const shouldUpdate = wrapper.shouldComponentUpdate(wrapper.props); expect(shouldUpdate).toBe(false); }); it('disabled click test', () => { const testClick = jest.fn(); const wrapper = mount(); wrapper.simulate('click'); expect(testClick).toHaveBeenCalledTimes(0); }); it('click test', () => { const testClick = jest.fn(); const wrapper = mount(); wrapper.simulate('click'); expect(testClick).toHaveBeenCalledTimes(1); }); it('accepts id', () => { const wrapper = mount( ); expect(wrapper.prop('id')).toEqual('testId'); }); it('accepts className', () => { const wrapper = mount( ); expect(wrapper.prop('className')).toEqual('test'); }); it('accepts style', () => { const wrapper = mount( ); expect(wrapper.getDOMNode().style).toHaveProperty('color', 'red'); }); });