import { createMemoryHistory } from 'history' ; import { noop } from 'lodash' ; import React from 'react' ; import { Observable } from 'rxjs' ; import { AppMountParameters , CoreStart } from 'src/core/public' ; import { themeServiceMock } from 'src/core/public/mocks' ; import { KibanaPageTemplate } from 'src/plugins/kibana_react/public' ; import { ObservabilityPublicPluginsStart } from '../plugin' ; import { createObservabilityRuleTypeRegistryMock } from '../rules/observability_rule_type_registry_mock' ; import { renderApp } from './' ; describe ( 'renderApp' , ( ) => { const originalConsole = global . console ; beforeAll ( ( ) => { global . console = { error : jest . fn ( ) } as unknown as typeof console ; } ) ; afterAll ( ( ) => { global . console = originalConsole ; } ) ; it ( 'renders' , async ( ) => { const plugins = { usageCollection : { reportUiCounter : noop } , data : { query : { timefilter : { timefilter : { setTime : jest . fn ( ) , getTime : jest . fn ( ) . mockImplementation ( ( ) => ( { } ) ) } , } , } , } , } as unknown as ObservabilityPublicPluginsStart ; const core = { application : { currentAppId$ : new Observable ( ) , navigateToUrl : noop } , chrome : { docTitle : { change : noop } , setBreadcrumbs : noop , setHelpExtension : noop , } , i18n : { Context : ( { children } ) => children } , uiSettings : { get : ( ) => false } , http : { basePath : { prepend : ( path ) => path } } , theme : themeServiceMock . createStartContract ( ) , } as unknown as CoreStart ; const config = { unsafe : { alertingExperience : { enabled : true } , cases : { enabled : true } , overviewNext : { enabled : false } , } , } ; const params = { element : window . document . createElement ( 'div' ) , history : createMemoryHistory ( ) , setHeaderActionMenu : noop , theme$ : themeServiceMock . createTheme$ ( ) , } as unknown as AppMountParameters ; expect ( ( ) => { const unmount = renderApp ( { config , core , plugins , appMountParameters : params , observabilityRuleTypeRegistry : createObservabilityRuleTypeRegistryMock ( ) , ObservabilityPageTemplate : KibanaPageTemplate , } ) ; unmount ( ) ; } ) . not . toThrowError ( ) ; } ) ; } ) ;