Skip to content

Commit

Permalink
Updated testing
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Dong <[email protected]>
  • Loading branch information
danieldong51 committed Jul 22, 2024
1 parent b27424f commit dbf2110
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 131 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { IndexPatternField } from '../../../../../data/common';
import { findTestSubject } from '@elastic/eui/lib/test';
import { FieldBucket } from './field_bucket';
import { Bucket } from './types';
import { EuiSmallButtonIcon } from '@elastic/eui';

const mockUseIndexPatterns = jest.fn(() => ({ selected: 'mockIndexPattern' }));
const mockUseOnAddFilter = jest.fn();
Expand All @@ -27,29 +26,6 @@ describe('visBuilder field bucket', function () {
}

it('should render with buttons if field is filterable', async () => {
// const props = {
// key: 'bucket1',
// bucket: {
// count: 100,
// display: 'display',
// percent: 5,
// value: '12',
// },
// field: new IndexPatternField(
// {
// name: 'bytes',
// type: 'number',
// esTypes: ['long'],
// count: 10,
// scripted: false,
// searchable: true,
// aggregatable: true,
// readFromDocValues: true,
// },
// 'bytes'
// ),
// };
// mountWithIntl(<FieldBucket {...props} />);
const field = new IndexPatternField(
{
name: 'bytes',
Expand All @@ -70,8 +46,13 @@ describe('visBuilder field bucket', function () {
count: 100,
};
const comp = mountComponent(field, bucket);
expect(findTestSubject(comp, 'plus-bytes-value').length).toBe(1);
expect(findTestSubject(comp, 'minus-bytes-value').length).toBe(1);
expect(comp.find(EuiSmallButtonIcon)).toMatchSnapshot();
const addButton = findTestSubject(comp, 'plus-bytes-value');
const minusButton = findTestSubject(comp, 'minus-bytes-value');
expect(addButton.length).toBe(1);
expect(minusButton.length).toBe(1);

addButton.simulate('click');
minusButton.simulate('click');
expect(mockUseOnAddFilter).toHaveBeenCalledTimes(2);
});
});

0 comments on commit dbf2110

Please sign in to comment.