Skip to content

Commit

Permalink
add jest test for es docs source UpdateSourceEditor component
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Oct 4, 2019
1 parent f03d4e4 commit 2902b84
Show file tree
Hide file tree
Showing 3 changed files with 349 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class UpdateSourceEditor extends Component {
<EuiSelect
disabled={!this.props.sortField}
options={[
{ label: 'ASC', value: SORT_ORDER.ASC },
{ label: 'DESC', value: SORT_ORDER.DESC }
{ text: 'ASC', value: SORT_ORDER.ASC },
{ text: 'DESC', value: SORT_ORDER.DESC }
]}
value={this.props.sortOrder}
onChange={this.onSortOrderChange}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

jest.mock('../../../kibana_services', () => ({}));

import React from 'react';
import { shallow } from 'enzyme';

import { UpdateSourceEditor } from './update_source_editor';

const defaultProps = {
indexPatternId: 'indexPattern1',
onChange: () => {},
filterByMapBounds: true,
tooltipProperties: [],
sortOrder: 'DESC',
useTopHits: false,
topHitsSplitField: 'trackId',
topHitsSize: 1,
};

test('should render update source editor', async () => {
const component = shallow(
<UpdateSourceEditor
{...defaultProps}
/>
);

expect(component).toMatchSnapshot();
});

test('should enable sort order select when sort field provided', async () => {
const component = shallow(
<UpdateSourceEditor
{...defaultProps}
sortField="@timestamp"
/>
);

expect(component).toMatchSnapshot();
});

test('should render top hits form when useTopHits is true', async () => {
const component = shallow(
<UpdateSourceEditor
{...defaultProps}
useTopHits={true}
/>
);

expect(component).toMatchSnapshot();
});

0 comments on commit 2902b84

Please sign in to comment.