-
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
* add title to UX data view * update useDataView Co-authored-by: Dominique Clarke <[email protected]>
- Loading branch information
1 parent
6efb2e3
commit 9e4734c
Showing
2 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
x-pack/plugins/apm/public/components/app/RumDashboard/LocalUIFilters/use_data_view.test.js
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,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import React from 'react'; | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import * as dynamicDataView from '../../../../hooks/use_dynamic_data_view'; | ||
import { useDataView } from './use_data_view'; | ||
import { MockApmPluginContextWrapper } from '../../../../context/apm_plugin/mock_apm_plugin_context'; | ||
import { KibanaContextProvider } from '../../../../../../../../src/plugins/kibana_react/public'; | ||
|
||
describe('useDataView', () => { | ||
const create = jest.fn(); | ||
const mockDataService = { | ||
data: { | ||
dataViews: { | ||
create, | ||
}, | ||
}, | ||
}; | ||
|
||
const title = 'apm-*'; | ||
jest | ||
.spyOn(dynamicDataView, 'useDynamicDataViewFetcher') | ||
.mockReturnValue({ dataView: { title } }); | ||
|
||
it('returns result as expected', async () => { | ||
const { waitForNextUpdate } = renderHook(() => useDataView(), { | ||
wrapper: ({ children }) => ( | ||
<MockApmPluginContextWrapper> | ||
<KibanaContextProvider services={mockDataService}> | ||
{children} | ||
</KibanaContextProvider> | ||
</MockApmPluginContextWrapper> | ||
), | ||
}); | ||
|
||
await waitForNextUpdate(); | ||
|
||
expect(create).toBeCalledWith({ title }); | ||
}); | ||
}); |
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