-
Notifications
You must be signed in to change notification settings - Fork 884
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MD] Create data source menu component able to be mount to nav bar (#…
…6082) * create data source menu component Signed-off-by: Lu Yu <nluyu@amazon.com> * add changelog Signed-off-by: Lu Yu <nluyu@amazon.com> --------- Signed-off-by: Lu Yu <nluyu@amazon.com>
- Loading branch information
Showing
14 changed files
with
795 additions
and
3 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
146 changes: 146 additions & 0 deletions
146
...nt/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
...anagement/public/components/data_source_menu/__snapshots__/data_source_menu.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
...ent/public/components/data_source_menu/__snapshots__/data_source_selectable.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
...ata_source_management/public/components/data_source_menu/create_data_source_menu.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,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { createDataSourceMenu } from './create_data_source_menu'; | ||
import { SavedObjectsClientContract } from '../../../../../core/public'; | ||
import { notificationServiceMock } from '../../../../../core/public/mocks'; | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('create data source menu', () => { | ||
let client: SavedObjectsClientContract; | ||
const notifications = notificationServiceMock.createStartContract(); | ||
|
||
beforeEach(() => { | ||
client = { | ||
find: jest.fn().mockResolvedValue([]), | ||
} as any; | ||
}); | ||
|
||
it('should render normally', () => { | ||
const props = { | ||
showDataSourceSelectable: true, | ||
appName: 'myapp', | ||
savedObjects: client, | ||
notifications, | ||
fullWidth: true, | ||
hideLocalCluster: true, | ||
disableDataSourceSelectable: false, | ||
className: 'myclass', | ||
}; | ||
const TestComponent = createDataSourceMenu(); | ||
const component = render(<TestComponent {...props} />); | ||
expect(component).toMatchSnapshot(); | ||
expect(client.find).toBeCalledWith({ | ||
fields: ['id', 'description', 'title'], | ||
perPage: 10000, | ||
type: 'data-source', | ||
}); | ||
expect(notifications.toasts.addWarning).toBeCalledTimes(0); | ||
}); | ||
}); |
Oops, something went wrong.