import React from 'react'; import sinon from 'sinon'; import { shallow } from 'enzyme'; import Button from '..'; const sandbox = sinon.sandbox.create(); describe('components/button/Button', () => { afterEach(() => { sandbox.verifyAndRestore(); }); test('should correctly render children in button', () => { const children = 'yooo'; const wrapper = shallow(); expect(wrapper.hasClass('btn')).toBe(true); expect(wrapper.find('.btn-content').length).toEqual(1); expect(wrapper.text()).toEqual(children); }); test('should correctly render loading indicator, disable button and hide button content if button is in loading state', () => { const wrapper = shallow(); expect(wrapper.find('.btn-loading-indicator').length).toEqual(1); expect(wrapper.hasClass('is-loading')).toBe(true); }); test('simulates click events', () => { const onClickHandler = sinon.spy(); const wrapper = shallow); expect(wrapper.find('RadarAnimation')).toMatchSnapshot(); }); test('should render a RadarAnimation if showRadar is true', () => { const wrapper = shallow(); expect(wrapper.find('RadarAnimation')).toMatchSnapshot(); }); });