import React from 'react' ; import { registerTestBed } from '@kbn/test/jest' ; import { RemoteClusterAdd } from '../../../public/application/sections' ; import { createRemoteClustersStore } from '../../../public/application/store' ; import { AppRouter , registerRouter } from '../../../public/application/services' ; import { createRemoteClustersActions } from '../helpers' ; import { AppContextProvider } from '../../../public/application/app_context' ; const ComponentWithContext = ( { isCloudEnabled } ) => { return ( < AppContextProvider context = { { isCloudEnabled , cloudBaseUrl : 'test.com' } } > < RemoteClusterAdd /> < /AppContextProvider>); } ; const testBedConfig = ( { isCloudEnabled } ) => { return { store : createRemoteClustersStore , memoryRouter : { onRouter : ( router ) => registerRouter ( router ) , } , defaultProps : { isCloudEnabled } , } ; } ; const initTestBed = ( isCloudEnabled ) => registerTestBed ( ComponentWithContext , testBedConfig ( { isCloudEnabled } ) ) ( ) ; export const setup = async ( isCloudEnabled = false ) => { const testBed = await initTestBed ( isCloudEnabled ) ; return { ... testBed , actions : { ... createRemoteClustersActions ( testBed ) , } , } ; } ;