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.
Signed-off-by: tygao <[email protected]>
- Loading branch information
Showing
5 changed files
with
115 additions
and
1 deletion.
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
23 changes: 23 additions & 0 deletions
23
src/core/public/chrome/ui/header/__snapshots__/right_navigation_button.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/core/public/chrome/ui/header/right_navigation_button.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,45 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { RightNavigationButton } from './right_navigation_button'; | ||
import { applicationServiceMock, httpServiceMock } from '../../../../../core/public/mocks'; | ||
|
||
const mockProps = { | ||
application: applicationServiceMock.createStartContract(), | ||
http: httpServiceMock.createStartContract(), | ||
appId: 'app_id', | ||
iconType: 'mock_icon', | ||
title: 'title', | ||
}; | ||
|
||
describe('Right navigation button', () => { | ||
it('should render base element normally', () => { | ||
const { baseElement } = render(<RightNavigationButton {...mockProps} />); | ||
expect(baseElement).toMatchSnapshot(); | ||
}); | ||
|
||
it('should call application getUrlForApp and navigateToUrl after clicked', () => { | ||
const navigateToUrl = jest.fn(); | ||
const getUrlForApp = jest.fn(); | ||
const props = { | ||
...mockProps, | ||
application: { | ||
...applicationServiceMock.createStartContract(), | ||
getUrlForApp, | ||
navigateToUrl, | ||
}, | ||
}; | ||
const { getByTestId } = render(<RightNavigationButton {...props} />); | ||
const icon = getByTestId('rightNavigationButton'); | ||
fireEvent.click(icon); | ||
expect(getUrlForApp).toHaveBeenCalledWith('app_id', { | ||
path: '/', | ||
absolute: false, | ||
}); | ||
expect(navigateToUrl).toHaveBeenCalled(); | ||
}); | ||
}); |
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