import React from 'react';
import { render } from '@testing-library/react';
import { AppConfigProvider } from '@theorchard/suite-frontend';
import { mockAppConfig } from 'lib/test-helpers/factories';
import PromoModal from '../promo-modal';

describe('PromoModal', () => {
    const renderComponent = (props: React.ComponentProps<typeof PromoModal>) =>
        render(
            <AppConfigProvider config={mockAppConfig}>
                <PromoModal {...props} />
            </AppConfigProvider>
        );

    describe('when shouldOpenModal is true', () => {
        const props = {
            shouldOpenModal: true,
            handleModalClose: jest.fn(),
        };
        it('renders the correct output', () => {
            const component = renderComponent(props);
            expect(component.baseElement).toMatchSnapshot();
        });
    });

    describe('when shouldOpenModal is false', () => {
        const props = {
            shouldOpenModal: false,
            handleModalClose: jest.fn(),
        };
        it('does not render the component', () => {
            const component = renderComponent(props);
            expect(component.baseElement).toMatchSnapshot();
        });
    });
});
