forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MD] Expose picker using function in data source management plugin se…
…tup (opensearch-project#6030) * expose picker using function in plugin setup Signed-off-by: Lu Yu <[email protected]> * add changelog and test Signed-off-by: Lu Yu <[email protected]> --------- Signed-off-by: Lu Yu <[email protected]>
- Loading branch information
Showing
6 changed files
with
276 additions
and
2 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
216 changes: 216 additions & 0 deletions
216
...nt/public/components/cluster_selector/__snapshots__/create_cluster_selector.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
...ata_source_management/public/components/cluster_selector/create_cluster_selector.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,40 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { createClusterSelector } from './create_cluster_selector'; | ||
import { SavedObjectsClientContract } from '../../../../../core/public'; | ||
import { notificationServiceMock } from '../../../../../core/public/mocks'; | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('create cluster selector', () => { | ||
let client: SavedObjectsClientContract; | ||
const { toasts } = notificationServiceMock.createStartContract(); | ||
|
||
beforeEach(() => { | ||
client = { | ||
find: jest.fn().mockResolvedValue([]), | ||
} as any; | ||
}); | ||
|
||
it('should render normally', () => { | ||
const props = { | ||
savedObjectsClient: client, | ||
notifications: toasts, | ||
onSelectedDataSource: jest.fn(), | ||
disabled: false, | ||
hideLocalCluster: false, | ||
fullWidth: false, | ||
}; | ||
const TestComponent = createClusterSelector(); | ||
const component = render(<TestComponent {...props} />); | ||
expect(component).toMatchSnapshot(); | ||
expect(client.find).toBeCalledWith({ | ||
fields: ['id', 'description', 'title'], | ||
perPage: 10000, | ||
type: 'data-source', | ||
}); | ||
expect(toasts.addWarning).toBeCalledTimes(0); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
...ins/data_source_management/public/components/cluster_selector/create_cluster_selector.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,11 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { ClusterSelector, ClusterSelectorProps } from './cluster_selector'; | ||
|
||
export function createClusterSelector() { | ||
return (props: ClusterSelectorProps) => <ClusterSelector {...props} />; | ||
} |
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