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

describe('Add Button', () => {
    it('renders correctly with primary type', () => {
        const onPressMock = jest.fn();
        const tree = renderer.create(<Add type="primary" onPress={onPressMock} />).toJSON();
        expect(tree).toMatchSnapshot();
    });

    it('renders correctly with secondary type', () => {
        const onPressMock = jest.fn();
        const tree = renderer.create(<Add type="secondary" onPress={onPressMock} />).toJSON();
        expect(tree).toMatchSnapshot();
    });

    it('renders correctly with disabled prop', () => {
        const onPressMock = jest.fn();
        const tree = renderer.create(<Add type="primary" onPress={onPressMock} disabled />).toJSON();
        expect(tree).toMatchSnapshot();
    });

    it('calls onPress function when clicked', () => {
        const onPressMock = jest.fn();
        const component = renderer.create(<Add type="primary" onPress={onPressMock} />);
        component.root.props.onPress(); // Simulate onPress directly on the Add component
        expect(onPressMock).toHaveBeenCalled();
    });
});
