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: Bharathwaj G <bharath78910@gmail.com>
- Loading branch information
1 parent
724b930
commit 8e3ba7a
Showing
13 changed files
with
932 additions
and
77 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
32 changes: 32 additions & 0 deletions
32
src/plugins/point_in_time_management/public/components/create_button/create_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,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { CreateButton } from './create_button'; | ||
import { scopedHistoryMock } from '../../../../../core/public/mocks'; | ||
import { ScopedHistory } from 'opensearch-dashboards/public'; | ||
|
||
const createButtonIdentifier = `[data-test-subj="createDataSourceButton"]`; | ||
|
||
describe('CreateButton', () => { | ||
const history = (scopedHistoryMock.create() as unknown) as ScopedHistory; | ||
const dataTestSubj = 'createDataSourceButton'; | ||
let component: ShallowWrapper<any, Readonly<{}>, React.Component<{}, {}, any>>; | ||
|
||
beforeEach(() => { | ||
component = shallow(<CreateButton history={history} dataTestSubj={dataTestSubj} />); | ||
}); | ||
|
||
it('should render normally', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('should click event normally', () => { | ||
component.find(createButtonIdentifier).first().simulate('click'); | ||
|
||
expect(history.push).toBeCalledWith('/create'); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
src/plugins/point_in_time_management/public/components/create_button/create_button.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,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { History } from 'history'; | ||
|
||
import { EuiButton } from '@elastic/eui'; | ||
import { FormattedMessage } from '@osd/i18n/react'; | ||
|
||
interface Props { | ||
history: History; | ||
isEmptyState?: boolean; | ||
dataTestSubj: string; | ||
} | ||
|
||
export const CreateButton = ({ history, isEmptyState, dataTestSubj }: Props) => { | ||
return ( | ||
<EuiButton | ||
data-test-subj={dataTestSubj} | ||
fill={isEmptyState ? false : true} | ||
onClick={() => history.push('/create')} | ||
> | ||
<FormattedMessage | ||
id="pit.createButton" | ||
defaultMessage="Create point in time" | ||
/> | ||
</EuiButton> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
src/plugins/point_in_time_management/public/components/create_button/index.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,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { CreateButton } from './create_button'; |
Oops, something went wrong.