[Discover] Add sidebar jest test (#76286)

* Add Jest test removed in #73226
This commit is contained in:
Matthias Wilhelm 2020-09-01 14:46:55 +02:00 committed by GitHub
parent 7c3ad238e5
commit 27bdc88011
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,11 +80,10 @@ function getComponent(selected = false, showDetails = false, useShortDots = fals
const props = {
indexPattern,
field,
getDetails: jest.fn(),
getDetails: jest.fn(() => ({ buckets: [], error: '', exists: 1, total: true, columns: [] })),
onAddFilter: jest.fn(),
onAddField: jest.fn(),
onRemoveField: jest.fn(),
onShowDetails: jest.fn(),
showDetails,
selected,
useShortDots,
@ -104,4 +103,9 @@ describe('discover sidebar field', function () {
findTestSubject(comp, 'fieldToggle-bytes').simulate('click');
expect(props.onRemoveField).toHaveBeenCalledWith('bytes');
});
it('should trigger getDetails', function () {
const { comp, props } = getComponent(true);
findTestSubject(comp, 'field-bytes-showDetails').simulate('click');
expect(props.getDetails).toHaveBeenCalledWith(props.field);
});
});