UNPKG

react-native-komect-uikit

Version:
37 lines (30 loc) 916 B
import React from 'react'; import { shallow } from 'enzyme'; import toJson from 'enzyme-to-json'; import Icon from '../Icon'; describe('Icon component', () => { it('should render without issues', () => { const component = shallow(<Icon name="wifi" />); expect(component.length).toBe(1); expect(toJson(component)).toMatchSnapshot(); }); it('should render with icon type', () => { const component = shallow( <Icon name="alert" type="octicon" reverse color="red" iconStyle={{ backgroundColor: 'peru' }} /> ); expect(component.length).toBe(1); expect(toJson(component)).toMatchSnapshot(); }); it('should have onPress event', () => { const onPress = jest.fn(); const component = shallow(<Icon onPress={onPress} name="wifi" />); component.simulate('press'); expect(onPress).toHaveBeenCalledTimes(1); }); });