Co-authored-by: Miriam <31922082+MiriamAparicio@users.noreply.github.com>
This commit is contained in:
parent
4b3d051539
commit
38f49bbd07
|
@ -12,6 +12,7 @@ import {
|
|||
waitForElementToBeRemoved,
|
||||
screen,
|
||||
} from '@testing-library/react';
|
||||
import { __IntlProvider as IntlProvider } from '@kbn/i18n/react';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import * as fetcherHook from '../../../../../hooks/use_fetcher';
|
||||
import { SelectableUrlList } from './SelectableUrlList';
|
||||
|
@ -32,35 +33,39 @@ describe('SelectableUrlList', () => {
|
|||
function WrappedComponent() {
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
return (
|
||||
<SelectableUrlList
|
||||
initialValue={'blog'}
|
||||
loading={false}
|
||||
data={{ items: [], total: 0 }}
|
||||
onChange={jest.fn()}
|
||||
searchValue={'blog'}
|
||||
onInputChange={jest.fn()}
|
||||
onTermChange={jest.fn()}
|
||||
popoverIsOpen={Boolean(isPopoverOpen)}
|
||||
setPopoverIsOpen={setIsPopoverOpen}
|
||||
onApply={jest.fn()}
|
||||
/>
|
||||
<IntlProvider locale="en">
|
||||
<SelectableUrlList
|
||||
initialValue={'blog'}
|
||||
loading={false}
|
||||
data={{ items: [], total: 0 }}
|
||||
onChange={jest.fn()}
|
||||
searchValue={'blog'}
|
||||
onInputChange={jest.fn()}
|
||||
onTermChange={jest.fn()}
|
||||
popoverIsOpen={Boolean(isPopoverOpen)}
|
||||
setPopoverIsOpen={setIsPopoverOpen}
|
||||
onApply={jest.fn()}
|
||||
/>
|
||||
</IntlProvider>
|
||||
);
|
||||
}
|
||||
|
||||
it('it uses search term value from url', () => {
|
||||
const { getByDisplayValue } = render(
|
||||
<SelectableUrlList
|
||||
initialValue={'blog'}
|
||||
loading={false}
|
||||
data={{ items: [], total: 0 }}
|
||||
onChange={jest.fn()}
|
||||
searchValue={'blog'}
|
||||
onInputChange={jest.fn()}
|
||||
onTermChange={jest.fn()}
|
||||
popoverIsOpen={false}
|
||||
setPopoverIsOpen={jest.fn()}
|
||||
onApply={jest.fn()}
|
||||
/>,
|
||||
<IntlProvider locale="en">
|
||||
<SelectableUrlList
|
||||
initialValue={'blog'}
|
||||
loading={false}
|
||||
data={{ items: [], total: 0 }}
|
||||
onChange={jest.fn()}
|
||||
searchValue={'blog'}
|
||||
onInputChange={jest.fn()}
|
||||
onTermChange={jest.fn()}
|
||||
popoverIsOpen={false}
|
||||
setPopoverIsOpen={jest.fn()}
|
||||
onApply={jest.fn()}
|
||||
/>
|
||||
</IntlProvider>,
|
||||
{ customHistory }
|
||||
);
|
||||
expect(getByDisplayValue('blog')).toBeInTheDocument();
|
||||
|
@ -68,18 +73,20 @@ describe('SelectableUrlList', () => {
|
|||
|
||||
it('maintains focus on search input field', () => {
|
||||
const { getByLabelText } = render(
|
||||
<SelectableUrlList
|
||||
initialValue={'blog'}
|
||||
loading={false}
|
||||
data={{ items: [], total: 0 }}
|
||||
onChange={jest.fn()}
|
||||
searchValue={'blog'}
|
||||
onInputChange={jest.fn()}
|
||||
onTermChange={jest.fn()}
|
||||
popoverIsOpen={false}
|
||||
setPopoverIsOpen={jest.fn()}
|
||||
onApply={jest.fn()}
|
||||
/>,
|
||||
<IntlProvider locale="en">
|
||||
<SelectableUrlList
|
||||
initialValue={'blog'}
|
||||
loading={false}
|
||||
data={{ items: [], total: 0 }}
|
||||
onChange={jest.fn()}
|
||||
searchValue={'blog'}
|
||||
onInputChange={jest.fn()}
|
||||
onTermChange={jest.fn()}
|
||||
popoverIsOpen={false}
|
||||
setPopoverIsOpen={jest.fn()}
|
||||
onApply={jest.fn()}
|
||||
/>
|
||||
</IntlProvider>,
|
||||
{ customHistory }
|
||||
);
|
||||
|
||||
|
|
|
@ -13,10 +13,12 @@ import { createMemoryHistory } from 'history';
|
|||
import { MemoryRouter, RouteComponentProps } from 'react-router-dom';
|
||||
import { CoreStart, DocLinksStart, HttpStart } from 'kibana/public';
|
||||
import { createKibanaReactContext } from 'src/plugins/kibana_react/public';
|
||||
import { createCallApmApi } from '../../../services/rest/createCallApmApi';
|
||||
|
||||
const { location } = createMemoryHistory();
|
||||
|
||||
const KibanaReactContext = createKibanaReactContext({
|
||||
notifications: { toasts: { add: () => {} } },
|
||||
usageCollection: { reportUiCounter: () => {} },
|
||||
observability: {
|
||||
navigation: {
|
||||
|
@ -39,7 +41,7 @@ const KibanaReactContext = createKibanaReactContext({
|
|||
observability: { guide: '' },
|
||||
},
|
||||
} as unknown as DocLinksStart,
|
||||
} as Partial<CoreStart>);
|
||||
} as unknown as Partial<CoreStart>);
|
||||
|
||||
function Wrapper({ children }: { children?: ReactNode }) {
|
||||
return (
|
||||
|
@ -52,6 +54,9 @@ function Wrapper({ children }: { children?: ReactNode }) {
|
|||
}
|
||||
|
||||
describe('Settings', () => {
|
||||
beforeEach(() => {
|
||||
createCallApmApi({} as CoreStart);
|
||||
});
|
||||
it('renders', async () => {
|
||||
const routerProps = {
|
||||
location,
|
||||
|
|
Loading…
Reference in a new issue