import React from 'react';
import renderer from 'react-test-renderer';
import {Stepper} from '../../Buttons/Stepper';

describe('Stepper', () => {
    it('should render with initial value', () => {
        const component = renderer.create(<Stepper value={0} onPress={() => {}} />);
        expect(component.toJSON()).toMatchSnapshot();
    });

    it('should increment value when plus button is pressed', () => {
        const onPressMock = jest.fn();
        const component = renderer.create(<Stepper value={0} onPress={onPressMock} />);
        component.root.props.onPress();
        expect(onPressMock).toHaveBeenCalled();
        expect(component.toJSON()).toMatchSnapshot();
    });

    it('should decrement value when minus button is pressed', () => {
        const onPressMock = jest.fn();
        const component = renderer.create(<Stepper value={1} onPress={onPressMock} />);
        component.root.props.onPress();
        expect(onPressMock).toHaveBeenCalled();
        expect(component.toJSON()).toMatchSnapshot();
    });
});