Skip to content

Commit

Permalink
rename function, impoved snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed May 17, 2020
1 parent c959006 commit 497638c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { IndexHeader } from './index_header';
import { IndexPatternTableItem } from '../types';
import { getIndexPatterns } from '../utils';

export interface EditIndexPatternProps extends RouteComponentProps {
interface EditIndexPatternProps extends RouteComponentProps {
indexPattern: IndexPattern;
config: IUiSettingsClient;
services: {
Expand Down Expand Up @@ -134,7 +134,7 @@ export const EditIndexPattern = withRouter(
});
};

const removePattern = () => {
const removePatternClick = () => {
async function doRemove() {
if (indexPattern.id === defaultIndex) {
const indexPatterns: IndexPatternTableItem[] = await getIndexPatterns(
Expand Down Expand Up @@ -198,7 +198,7 @@ export const EditIndexPattern = withRouter(
indexPattern={indexPattern}
setDefault={setDefaultPattern}
refreshFields={refreshFields}
deleteIndexPattern={removePattern}
deleteIndexPatternClick={removePatternClick}
defaultIndex={defaultIndex}
/>
<EuiSpacer size="s" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { getEditBreadcrumbs } from '../breadcrumbs';

import { EditIndexPattern } from '../edit_index_pattern';

export interface EditIndexPatternContainerProps extends RouteComponentProps<{ id: string }> {
interface EditIndexPatternContainerProps extends RouteComponentProps<{ id: string }> {
getIndexPattern: (id: string) => Promise<IndexPattern>;
config: IUiSettingsClient;
services: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface IndexHeaderProps {
defaultIndex?: string;
setDefault?: () => void;
refreshFields?: () => void;
deleteIndexPattern?: () => void;
deleteIndexPatternClick?: () => void;
}

const setDefaultAriaLabel = i18n.translate(
Expand Down Expand Up @@ -72,7 +72,7 @@ export function IndexHeader({
indexPattern,
setDefault,
refreshFields,
deleteIndexPattern,
deleteIndexPatternClick,
}: IndexHeaderProps) {
return (
<EuiFlexGroup justifyContent="spaceBetween" alignItems="center">
Expand Down Expand Up @@ -120,12 +120,12 @@ export function IndexHeader({
</EuiFlexItem>
)}

{deleteIndexPattern && (
{deleteIndexPatternClick && (
<EuiFlexItem>
<EuiToolTip content={removeTooltip}>
<EuiButtonIcon
color="danger"
onClick={deleteIndexPattern}
onClick={deleteIndexPatternClick}
iconType="trash"
aria-label={removeAriaLabel}
data-test-subj="deleteIndexPatternButton"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@
*/

import React from 'react';
import { shallow } from 'enzyme';
import { render } from 'enzyme';
import { RouteComponentProps } from 'react-router-dom';

import { Header } from './header';

describe('Header', () => {
test('should render normally', () => {
const component = shallow(<Header indexPatternId="test" />);
const component = render(
<Header.WrappedComponent
indexPatternId="test"
history={({} as unknown) as RouteComponentProps['history']}
location={({} as unknown) as RouteComponentProps['location']}
match={({} as unknown) as RouteComponentProps['match']}
/>
);

expect(component).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit 497638c

Please sign in to comment.