-
Notifications
You must be signed in to change notification settings - Fork 918
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: SuZhou-Joe <[email protected]>
- Loading branch information
1 parent
3a41f7b
commit f1f06ee
Showing
4 changed files
with
55 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
src/plugins/home/public/application/components/home_icon.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,19 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { HomeIcon } from './home_icon'; | ||
import { coreMock } from '../../../../../core/public/mocks'; | ||
|
||
describe('<HomeIcon />', () => { | ||
it('should call chrome.navGroup.setCurrentNavGroup and application.navigateToApp methods from core service when click', () => { | ||
const coreStartMock = coreMock.createStart(); | ||
const { container } = render(<HomeIcon core={coreStartMock} appId="foo" />); | ||
const component = container.children[0]; | ||
fireEvent.click(component); | ||
expect(coreStartMock.application.navigateToApp).toBeCalledWith('foo'); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/plugins/home/public/application/components/home_icon.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,20 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiButtonIcon } from '@elastic/eui'; | ||
import { CoreStart } from 'opensearch-dashboards/public'; | ||
|
||
export function HomeIcon({ core, appId }: { core: CoreStart; appId: string }) { | ||
return ( | ||
<EuiButtonIcon | ||
aria-label="go-to-home" | ||
iconType="home" | ||
onClick={() => { | ||
core.application.navigateToApp(appId); | ||
}} | ||
/> | ||
); | ||
} |
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