import * as React from 'react';
import { renderHook } from '@testing-library/react';
import { AppConfigContext, useAppConfig } from '../appConfigContext';
import { createConfig } from './mocks';
import type { SuiteAppConfig } from '../types';

describe('useAppConfig', () => {
    const config = createConfig();

    const renderConfigHook = (config?: SuiteAppConfig) =>
        renderHook(() => useAppConfig(), {
            wrapper: ({ children }: { children: React.ReactNode }) => (
                <AppConfigContext.Provider value={{ config }}>{children}</AppConfigContext.Provider>
            ),
        });

    test('returns config in context', () => {
        const { result } = renderConfigHook(config);
        expect(result.current).toEqual(config);
    });
});
