Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
mbondyra committed Sep 16, 2020
1 parent 9181d0b commit fc1f983
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
*/

import React from 'react';
import { i18n } from '@kbn/i18n';
import { mount, shallow } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { EuiIcon } from '@elastic/eui';
import { NewBucketButton, DragDropBuckets, DraggableBucketContainer } from '../shared_components';
import { DragDropBuckets, DraggableBucketContainer } from '../shared_components';

jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');
return {
...original,
EuiDragDropContext: 'eui-drag-drop-context',
EuiDroppable: 'eui-droppable',
EuiDraggable: (props) => props.children({ dragHandleProps: {} }),
EuiDraggable: (props: any) => props.children(), // eslint-disable-line @typescript-eslint/no-explicit-any
};
});

describe('buckets shared components', () => {
describe('DragDropBuckets', () => {
it('should call onDragEnd when dragging ended with reordered items', () => {
const items = ['first', 'second', 'third'];
const items = [<div key="1">first</div>, <div key="2">second</div>, <div key="3">third</div>];
const defaultProps = {
items,
onDragStart: jest.fn(),
Expand All @@ -38,7 +37,11 @@ describe('buckets shared components', () => {
instance.props().onDragEnd({ source: { index: 0 }, destination: { index: 1 } });
});

expect(defaultProps.onDragEnd).toHaveBeenCalledWith(['second', 'first', 'third']);
expect(defaultProps.onDragEnd).toHaveBeenCalledWith([
<div key="2">second</div>,
<div key="1">first</div>,
<div key="3">third</div>,
]);
});
});
describe('DraggableBucketContainer', () => {
Expand All @@ -48,7 +51,7 @@ describe('buckets shared components', () => {
onRemoveClick: jest.fn(),
removeTitle: 'remove',
children: <div data-test-subj="popover">popover</div>,
id: 0,
id: '0',
idx: 0,
};
it('should render valid component', () => {
Expand Down

0 comments on commit fc1f983

Please sign in to comment.