import React from 'react';
import { screen } from '@testing-library/react';
import { FeatureFlagDictionary } from '@theorchard/suite-frontend';
import { createIdentity, renderInAppContext } from '@theorchard/suite-testing';
import IdLookupSidecar, { Props } from '../idLookupSidecar';

describe('<IdLookupSidecar>', () => {
    const defaultProps: Props = {
        open: true,
        closeSidecar: jest.fn(),
    };

    const renderWrapper = (props?: Props, features?: FeatureFlagDictionary) => {
        const identity = createIdentity({ features: features || {} });

        renderInAppContext(<IdLookupSidecar {...defaultProps} {...props} />, {
            identity,
        });
    };

    test('displays contributor search & participant search', async () => {
        renderWrapper();

        const dropdown = await screen.findByTestId(
            'Dropdown_accountSearchDropdown'
        );
        const accountDropdown = await screen.findByTestId(
            'IdLookupSidecar-account-lookup'
        );

        expect(dropdown).toBeTruthy();
        expect(accountDropdown).toBeTruthy();
    });
});
