-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: tygao <[email protected]>
- Loading branch information
Showing
6 changed files
with
91 additions
and
5 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
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
48 changes: 48 additions & 0 deletions
48
src/plugins/data_source_management/public/service/data_source_selection_service.test.ts
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,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
import { DataSourceSelection } from './data_source_selection_service'; | ||
import { generateComponentId } from '../components/utils'; | ||
|
||
describe('DataSourceSelection service', () => { | ||
it('basic set, get and remove', async () => { | ||
const dataSourceSelection = new DataSourceSelection(); | ||
const id = generateComponentId(); | ||
const dataSource = { id: 'id', label: 'label' }; | ||
expect(dataSourceSelection.getSelectionValue().get(id)).toBe(undefined); | ||
dataSourceSelection.selectDataSource(id, [dataSource]); | ||
expect(dataSourceSelection.getSelectionValue().get(id)).toStrictEqual([dataSource]); | ||
dataSourceSelection.remove(id); | ||
expect(dataSourceSelection.getSelectionValue().get(id)).toBe(undefined); | ||
}); | ||
|
||
it('multiple set and get', async () => { | ||
const dataSourceSelection = new DataSourceSelection(); | ||
const id1 = generateComponentId(); | ||
const id2 = generateComponentId(); | ||
|
||
const dataSource = { id: 'id', label: 'label' }; | ||
expect(dataSourceSelection.getSelectionValue().get(id1)).toBe(undefined); | ||
expect(dataSourceSelection.getSelectionValue().get(id2)).toBe(undefined); | ||
dataSourceSelection.selectDataSource(id1, [dataSource]); | ||
dataSourceSelection.selectDataSource(id2, [dataSource]); | ||
expect(dataSourceSelection.getSelectionValue().get(id1)).toStrictEqual([dataSource]); | ||
expect(dataSourceSelection.getSelectionValue().get(id2)).toStrictEqual([dataSource]); | ||
dataSourceSelection.remove(id1); | ||
expect(dataSourceSelection.getSelectionValue().get(id1)).toBe(undefined); | ||
expect(dataSourceSelection.getSelectionValue().get(id2)).toStrictEqual([dataSource]); | ||
}); | ||
|
||
it('support subscribing selected observable', (done) => { | ||
const dataSourceSelection = new DataSourceSelection(); | ||
const selectedDataSource$ = dataSourceSelection.getSelection$(); | ||
const id = generateComponentId(); | ||
const dataSource = { id: 'id', label: 'label' }; | ||
dataSourceSelection.selectDataSource(id, [dataSource]); | ||
selectedDataSource$.subscribe((newValue) => { | ||
expect(newValue.get(id)).toStrictEqual([dataSource]); | ||
done(); | ||
}); | ||
}); | ||
}); |
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
34 changes: 34 additions & 0 deletions
34
src/plugins/navigation/public/top_nav_menu/__snapshots__/top_nav_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.
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