import React, { ReactElement } from 'react';
import { Identity } from '@theorchard/suite-frontend';
import { renderInAppContext } from '@theorchard/suite-testing';
import * as mockIdentity from 'src/__fixtures__/identity.json';
import { ABACUS_PROFILE } from 'src/constants';
import RestrictedByAbacusProfileWrapper from '../restricted-by-abacus-profile-wrapper';

describe('<RestrictedByAbacusProfileWrapper>', () => {
    const content = <div>testContent</div>;
    const renderWrapper = (children?: ReactElement, identity?: Identity) =>
        renderInAppContext(
            <RestrictedByAbacusProfileWrapper>
                {children}
            </RestrictedByAbacusProfileWrapper>,
            {
                identity,
            }
        );

    beforeEach(() => {
        jest.clearAllMocks();
    });

    test('renders content if user has ABACUS profile', () => {
        const { getByText } = renderWrapper(content, {
            ...mockIdentity,
            profileType: ABACUS_PROFILE,
        });

        expect(getByText('testContent')).toBeVisible();
    });

    test('does not renders content for non ABACUS users', () => {
        const { queryByText } = renderWrapper(content, {
            ...mockIdentity,
            profileType: 'InsightsProfile',
        });

        expect(queryByText('testContent')).toBeNull();
    });
});
