diff --git a/scripts/babel/proptypes-from-ts-props/index.js b/scripts/babel/proptypes-from-ts-props/index.js
index 7aa74afcbb6..dbb40fc504b 100644
--- a/scripts/babel/proptypes-from-ts-props/index.js
+++ b/scripts/babel/proptypes-from-ts-props/index.js
@@ -1151,7 +1151,10 @@ const typeDefinitionExtractors = {
*/
VariableDeclaration: node => {
return node.declarations.reduce((declarations, declaration) => {
- if (declaration.init.type === 'ObjectExpression') {
+ if (
+ declaration.init != null &&
+ declaration.init.type === 'ObjectExpression'
+ ) {
declarations.push({
name: declaration.id.name,
definition: declaration.init,
diff --git a/scripts/babel/proptypes-from-ts-props/index.test.js b/scripts/babel/proptypes-from-ts-props/index.test.js
index 0a3be09d385..4f537e062c6 100644
--- a/scripts/babel/proptypes-from-ts-props/index.test.js
+++ b/scripts/babel/proptypes-from-ts-props/index.test.js
@@ -2613,6 +2613,18 @@ FooComponent.propTypes = {
});
});
+ describe('misc', () => {
+ it('supports non-initialized variable declarations', () => {
+ const result = transform(
+ `
+let something: any;
+`,
+ babelOptions
+ );
+
+ expect(result.code).toBe('let something;');
+ });
+ });
});
describe('remove types from exports', () => {
diff --git a/src/components/modal/confirm_modal.test.tsx b/src/components/modal/confirm_modal.test.tsx
index 26ee5d270a7..2ccbf635642 100644
--- a/src/components/modal/confirm_modal.test.tsx
+++ b/src/components/modal/confirm_modal.test.tsx
@@ -10,151 +10,153 @@ import {
EuiConfirmModal,
} from './confirm_modal';
-let onConfirm: any;
-let onCancel: any;
+let onConfirm: jest.Mock;
+let onCancel: jest.Mock;
beforeEach(() => {
onConfirm = jest.fn();
onCancel = jest.fn();
});
-test('renders EuiConfirmModal', () => {
- const component = render(
- {}}
- onConfirm={onConfirm}
- cancelButtonText="Cancel Button Text"
- confirmButtonText="Confirm Button Text"
- {...requiredProps}>
- This is a confirmation modal example
-
- );
- expect(component).toMatchSnapshot();
-});
-
-test('renders EuiConfirmModal without EuiModalBody, if empty', () => {
- const component = render(
- {}}
- onConfirm={onConfirm}
- cancelButtonText="Cancel Button Text"
- confirmButtonText="Confirm Button Text"
- {...requiredProps}
- />
- );
- expect(component).toMatchSnapshot();
-});
-
-test('onConfirm', () => {
- const component = mount(
-
- );
-
- findTestSubject(component, 'confirmModalConfirmButton').simulate('click');
- expect(onConfirm).toHaveBeenCalledTimes(1);
- expect(onCancel).toHaveBeenCalledTimes(0);
-});
-
-test('onConfirm can be disabled', () => {
- const component = mount(
-
- );
-
- findTestSubject(component, 'confirmModalConfirmButton').simulate('click');
- expect(onConfirm).toHaveBeenCalledTimes(0);
- expect(onCancel).toHaveBeenCalledTimes(0);
-});
-
-describe('onCancel', () => {
- test('triggerd by click', () => {
- const component = mount(
+describe('EuiConfirmModal', () => {
+ test('renders EuiConfirmModal', () => {
+ const component = render(
{}}
onConfirm={onConfirm}
cancelButtonText="Cancel Button Text"
confirmButtonText="Confirm Button Text"
- />
+ {...requiredProps}>
+ This is a confirmation modal example
+
);
-
- findTestSubject(component, 'confirmModalCancelButton').simulate('click');
- expect(onConfirm).toHaveBeenCalledTimes(0);
- expect(onCancel).toHaveBeenCalledTimes(1);
+ expect(component).toMatchSnapshot();
});
- test('triggered by esc key', () => {
- const component = mount(
+ test('renders EuiConfirmModal without EuiModalBody, if empty', () => {
+ const component = render(
{}}
onConfirm={onConfirm}
cancelButtonText="Cancel Button Text"
confirmButtonText="Confirm Button Text"
- data-test-subj="modal"
+ {...requiredProps}
/>
);
-
- findTestSubject(component, 'modal').simulate('keydown', {
- keyCode: keyCodes.ESCAPE,
- });
- expect(onConfirm).toHaveBeenCalledTimes(0);
- expect(onCancel).toHaveBeenCalledTimes(1);
+ expect(component).toMatchSnapshot();
});
-});
-describe('defaultFocusedButton', () => {
- test('is cancel', done => {
+ test('onConfirm', () => {
const component = mount(
);
- // The auto-focus implementation waits a frame before focusing.
- requestAnimationFrame(() => {
- const button = findTestSubject(
- component,
- 'confirmModalCancelButton'
- ).getDOMNode();
- expect(document.activeElement).toEqual(button);
- done();
- });
+ findTestSubject(component, 'confirmModalConfirmButton').simulate('click');
+ expect(onConfirm).toHaveBeenCalledTimes(1);
+ expect(onCancel).toHaveBeenCalledTimes(0);
});
- test('is confirm', done => {
+ test('onConfirm can be disabled', () => {
const component = mount(
);
- // The auto-focus implementation waits a frame before focusing.
- requestAnimationFrame(() => {
- const button = findTestSubject(
- component,
- 'confirmModalConfirmButton'
- ).getDOMNode();
- expect(document.activeElement).toEqual(button);
- done();
+ findTestSubject(component, 'confirmModalConfirmButton').simulate('click');
+ expect(onConfirm).toHaveBeenCalledTimes(0);
+ expect(onCancel).toHaveBeenCalledTimes(0);
+ });
+
+ describe('onCancel', () => {
+ test('triggerd by click', () => {
+ const component = mount(
+
+ );
+
+ findTestSubject(component, 'confirmModalCancelButton').simulate('click');
+ expect(onConfirm).toHaveBeenCalledTimes(0);
+ expect(onCancel).toHaveBeenCalledTimes(1);
+ });
+
+ test('triggered by esc key', () => {
+ const component = mount(
+
+ );
+
+ findTestSubject(component, 'modal').simulate('keydown', {
+ keyCode: keyCodes.ESCAPE,
+ });
+ expect(onConfirm).toHaveBeenCalledTimes(0);
+ expect(onCancel).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ describe('defaultFocusedButton', () => {
+ test('is cancel', done => {
+ const component = mount(
+
+ );
+
+ // The auto-focus implementation waits a frame before focusing.
+ requestAnimationFrame(() => {
+ const button = findTestSubject(
+ component,
+ 'confirmModalCancelButton'
+ ).getDOMNode();
+ expect(document.activeElement).toEqual(button);
+ done();
+ });
+ });
+
+ test('is confirm', done => {
+ const component = mount(
+
+ );
+
+ // The auto-focus implementation waits a frame before focusing.
+ requestAnimationFrame(() => {
+ const button = findTestSubject(
+ component,
+ 'confirmModalConfirmButton'
+ ).getDOMNode();
+ expect(document.activeElement).toEqual(button);
+ done();
+ });
});
});
});