From 295ce3d41fe45d7c554c50670e2411e5199e5435 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 7 May 2019 12:36:07 +0100 Subject: [PATCH] `EuiFormControlLayoutClearButton` converted to TS --- ..._control_layout_clear_button.test.tsx.snap | 23 +++++++++++++++ .../form_control_layout_clear_button.test.tsx | 16 +++++++++++ ...s => form_control_layout_clear_button.tsx} | 28 ++++++++----------- .../form/form_control_layout/index.d.ts | 8 ++++++ src/components/form/index.d.ts | 2 ++ 5 files changed, 60 insertions(+), 17 deletions(-) create mode 100644 src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap create mode 100644 src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx rename src/components/form/form_control_layout/{form_control_layout_clear_button.js => form_control_layout_clear_button.tsx} (54%) create mode 100644 src/components/form/form_control_layout/index.d.ts diff --git a/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap b/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap new file mode 100644 index 000000000000..13ff7d761c89 --- /dev/null +++ b/src/components/form/form_control_layout/__snapshots__/form_control_layout_clear_button.test.tsx.snap @@ -0,0 +1,23 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EuiFormControlLayoutClearButton is rendered 1`] = ` + +`; diff --git a/src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx b/src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx new file mode 100644 index 000000000000..b5964bb44eac --- /dev/null +++ b/src/components/form/form_control_layout/form_control_layout_clear_button.test.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { render } from 'enzyme'; +import { EuiFormControlLayoutClearButton } from './form_control_layout_clear_button'; + +describe('EuiFormControlLayoutClearButton', () => { + test('is rendered', () => { + const clear = { + onClick: () => null, + className: 'customClass', + 'data-test-subj': 'clearButton', + }; + const component = render(); + + expect(component).toMatchSnapshot(); + }); +}); diff --git a/src/components/form/form_control_layout/form_control_layout_clear_button.js b/src/components/form/form_control_layout/form_control_layout_clear_button.tsx similarity index 54% rename from src/components/form/form_control_layout/form_control_layout_clear_button.js rename to src/components/form/form_control_layout/form_control_layout_clear_button.tsx index d243af3d84fe..49e9443a0c62 100644 --- a/src/components/form/form_control_layout/form_control_layout_clear_button.js +++ b/src/components/form/form_control_layout/form_control_layout_clear_button.tsx @@ -1,27 +1,26 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import classNames from 'classnames'; +import React, { FunctionComponent, HTMLAttributes } from 'react'; +import classNames from 'classnames'; +import { CommonProps } from '../../common'; import { EuiIcon } from '../../icon'; import { EuiI18n } from '../../i18n'; -export const EuiFormControlLayoutClearButton = ({ - className, - onClick, - ...rest -}) => { +export const EuiFormControlLayoutClearButton: FunctionComponent< + CommonProps & HTMLAttributes +> = ({ className, onClick, ...rest }) => { const classes = classNames('euiFormControlLayoutClearButton', className); return ( - - {label => ( + + {(label: string) => (