import React from 'react';
// Import enzyme's shallow renderer
import { shallow } from 'enzyme';
// Describes a test group
describe('Button', () => {
it('renders correctly with a text', () => {
// Render our button with a text inside
const wrapper = shallow(<Button>test</Button>);
// Check that the rendered button matches
// previously saved snapshot
expect(wrapper).toMatchSnapshot();
it('renders correctly with an image', () => {
// Render our button with an image inside
<Image src={require('something')} />
// Check that the rendered button matches
// previously saved snapshot
expect(wrapper).toMatchSnapshot();
it('handles onPress', () => {
// Create a mock function to pass as a handler
const onPress = jest.fn();
// Render our button with an image inside
const wrapper = shallow(<Button onPress={onPress}>test</Button>);
// Find a TouchableOpacity and press it
.find('TouchableOpacity')
// Check that our handler have been called 1 time
expect(onPress).toHaveBeenCalledTimes(1);