-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
7ecedd1
commit c5d28ef
Showing
4 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...blic/components/app/RumDashboard/URLFilter/URLSearch/__tests__/SelectableUrlList.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
import { createMemoryHistory } from 'history'; | ||
import * as fetcherHook from '../../../../../../hooks/useFetcher'; | ||
import { SelectableUrlList } from '../SelectableUrlList'; | ||
import { render } from '../../../utils/test_helper'; | ||
|
||
describe('SelectableUrlList', () => { | ||
it('it uses search term value from url', () => { | ||
jest.spyOn(fetcherHook, 'useFetcher').mockReturnValue({ | ||
data: {}, | ||
status: fetcherHook.FETCH_STATUS.SUCCESS, | ||
refetch: jest.fn(), | ||
}); | ||
|
||
const customHistory = createMemoryHistory({ | ||
initialEntries: ['/?searchTerm=blog'], | ||
}); | ||
|
||
const { getByDisplayValue } = render( | ||
<SelectableUrlList | ||
initialValue={'blog'} | ||
loading={false} | ||
data={{ items: [], total: 0 }} | ||
onChange={jest.fn()} | ||
searchValue={'blog'} | ||
onClose={jest.fn()} | ||
onInputChange={jest.fn()} | ||
onTermChange={jest.fn()} | ||
popoverIsOpen={false} | ||
setPopoverIsOpen={jest.fn()} | ||
/>, | ||
{ customHistory } | ||
); | ||
expect(getByDisplayValue('blog')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
x-pack/plugins/apm/public/components/app/RumDashboard/utils/test_helper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render as testLibRender } from '@testing-library/react'; | ||
import { CoreStart } from 'kibana/public'; | ||
import { of } from 'rxjs'; | ||
import { createMemoryHistory } from 'history'; | ||
import { Router } from 'react-router-dom'; | ||
import { MemoryHistory } from 'history'; | ||
import { EuiThemeProvider } from '../../../../../../observability/public'; | ||
import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; | ||
import { UrlParamsProvider } from '../../../../context/UrlParamsContext'; | ||
|
||
export const core = ({ | ||
http: { | ||
basePath: { | ||
prepend: jest.fn(), | ||
}, | ||
}, | ||
uiSettings: { | ||
get: (key: string) => true, | ||
get$: (key: string) => of(true), | ||
}, | ||
} as unknown) as CoreStart; | ||
|
||
export const render = ( | ||
component: React.ReactNode, | ||
options: { customHistory: MemoryHistory } | ||
) => { | ||
const history = options?.customHistory ?? createMemoryHistory(); | ||
|
||
history.location.key = 'TestKeyForTesting'; | ||
|
||
return testLibRender( | ||
<Router history={history}> | ||
<KibanaContextProvider services={{ ...core }}> | ||
<UrlParamsProvider> | ||
<EuiThemeProvider>{component}</EuiThemeProvider> | ||
</UrlParamsProvider> | ||
</KibanaContextProvider> | ||
</Router> | ||
); | ||
}; |