import React, { ReactElement, ReactNode } from 'react';
import { ResourceBrowserContextProps, ResourceBrowserContextProvider } from '../ResourceBrowserContext/ResourceBrowserContext';
import { render } from '@testing-library/react';

export const renderWithContext = (ui: ReactElement, context: Partial<ResourceBrowserContextProps> = {}) => {
    return render(ui, {
        wrapper: ({ children }: { children: ReactNode }): ReactElement => (
            <ResourceBrowserContextProvider
                value={{
                    onRequestSources: jest.fn(),
                    plugins: [],
                    searchEnabled: false,
                    ...context,
                }}
            >
                {children}
            </ResourceBrowserContextProvider>
        ),
    });
};
