import React from 'react' ; import { Router } from 'react-router-dom' ; import { render } from '@testing-library/react' ; import { createBrowserHistory } from 'history' ; import { I18nProvider } from '@kbn/i18n-react' ; import { AnomalyResultsViewSelector } from './index' ; jest . mock ( '../../contexts/kibana' , ( ) => { return { useMlLocator : ( ) => require ( '../../../../../../../src/plugins/share/public/mocks' ) . sharePluginMock . createLocator ( ) , useNavigateToPath : ( ) => jest . fn ( ) , } ; } ) ; describe ( 'AnomalyResultsViewSelector' , ( ) => { test ( 'should create selector with correctly selected value' , ( ) => { const history = createBrowserHistory ( ) ; const { getByTestId } = render ( < I18nProvider > < Router history = { history } > < AnomalyResultsViewSelector viewId = "timeseriesexplorer" / > < /Router> < /I18nProvider>); expect ( getByTestId ( 'mlAnomalyResultsViewSelectorSingleMetricViewer' ) ) . toBeInTheDocument ( ) ; expect ( getByTestId ( 'mlAnomalyResultsViewSelectorSingleMetricViewer' ) . querySelector ( 'input' ) ! . hasAttribute ( 'checked' ) ) . toBe ( true ) ; } ) ; } ) ;