@shopgate/pwa-common
Version:
Common library for the Shopgate Connect PWA.
1 lines • 1.07 kB
JavaScript
import React from'react';import{shallow}from'enzyme';import Button from"./index";describe('<Button />',function(){it('should render the button',function(){var wrapper=shallow(React.createElement(Button,null,"My content"));expect(wrapper).toMatchSnapshot();expect(wrapper.find('button').length).toBe(1);});it('should render the button in disabled state',function(){var wrapper=shallow(React.createElement(Button,{disabled:true},"My content"));expect(wrapper).toMatchSnapshot();expect(wrapper.find('button[disabled]').length).toBe(1);});it('should trigger the click event',function(){var callback=jest.fn();var wrapper=shallow(React.createElement(Button,{onClick:callback},"My content"));wrapper.simulate('click');expect(wrapper).toMatchSnapshot();expect(callback).toHaveBeenCalled();});it('should not trigger the click event when disabled',function(){var callback=jest.fn();var wrapper=shallow(React.createElement(Button,{disabled:true,onClick:callback},"My content"));wrapper.simulate('click');expect(wrapper).toMatchSnapshot();expect(callback).not.toHaveBeenCalled();});});