import React from 'react' ; import { render , act } from '@testing-library/react' ; import { MenuItem } from './menu_item' ; import { createStateContainer } from '../../../../../../../../src/plugins/kibana_utils/public' ; import { UiActionsEnhancedDynamicActionManager as DynamicActionManager } from '../../../../../../ui_actions_enhanced/public' ; import { EnhancedEmbeddable } from '../../../../../../embeddable_enhanced/public' ; test ( '<MenuItem/>' , ( ) => { const state = createStateContainer < { events : object [ ] ; } > ( { events : [ ] } ) ; const { getByText , queryByText } = render ( < MenuItem context = { { embeddable : { enhancements : { dynamicActions : { state } as unknown as DynamicActionManager , } , } as unknown as EnhancedEmbeddable , trigger : { } as any , } } />); expect ( getByText ( /manage drilldowns/i ) ) . toBeInTheDocument ( ) ; expect ( queryByText ( '0' ) ) . not . toBeInTheDocument ( ) ; act ( ( ) => { state . set ( { events : [ { } ] } ) ; } ) ; expect ( queryByText ( '1' ) ) . toBeInTheDocument ( ) ; } ) ;