import { render } from '@testing-library/react';
import React from 'react';
import OptionalTooltip from '../optional-tooltip';
import type { OptionalTooltipProps } from '../optional-tooltip';

describe('<OptionalTooltip/>', () => {
    const childText = 'child';

    const id = 'great';
    const message = 'Oh no! Anyway...';
    const children = <div>{childText}</div>;

    const defaultProps: OptionalTooltipProps = {
        id,
        message,
        children,
        enabled: true,
    };

    const renderWrapper = (props: Partial<OptionalTooltipProps> = {}) =>
        render(<OptionalTooltip {...defaultProps} {...props} />);

    test('matches snapshot', () => {
        const { container } = renderWrapper();
        expect(container).toMatchSnapshot();
    });

    describe('enabled === false', () => {
        describe('Tooltip', () => {
            test('does not render', () => {
                const { queryByTestId } = renderWrapper({ enabled: false });
                expect(queryByTestId('Tooltip')).toBeNull();
            });
        });
    });
});
