Skip to content

Commit

Permalink
Move test utils inside the input_control_vis (#55169)
Browse files Browse the repository at this point in the history
* Move test utils to an appropriate folder

* Change imports

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
sulemanof and elasticmachine committed Jan 22, 2020
1 parent 1f10da8 commit ed04b17
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import React from 'react';
import { shallowWithIntl, mountWithIntl } from 'test_utils/enzyme_helpers';
// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { getDepsMock } from './__tests__/get_deps_mock';
import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';
import { getDepsMock, getIndexPatternMock } from '../../test_utils';
import { ControlsTab, ControlsTabUiProps } from './controls_tab';

const indexPatternsMock = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ import { shallow } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';

import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
import { getDepsMock } from './__tests__/get_deps_mock';
import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';
import { getIndexPatternMock } from '../../test_utils/get_index_pattern_mock';
import { ListControlEditor } from './list_control_editor';
import { ControlParams } from '../../editor_utils';
import { updateComponent } from './__tests__/update_component';
import { getDepsMock, updateComponent } from '../../test_utils';

const controlParamsBase: ControlParams = {
id: '1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers';

// @ts-ignore
import { findTestSubject } from '@elastic/eui/lib/test';
import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';

import { RangeControlEditor } from './range_control_editor';
import { ControlParams } from '../../editor_utils';
import { getDepsMock } from './__tests__/get_deps_mock';
import { updateComponent } from './__tests__/update_component';
import { getDepsMock } from '../../test_utils/get_deps_mock';
import { getIndexPatternMock, updateComponent } from '../../test_utils';

const controlParams: ControlParams = {
id: '1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import { listControlFactory, ListControl } from './list_control_factory';
import { ControlParams, CONTROL_TYPES } from '../editor_utils';
import { getDepsMock } from '../components/editor/__tests__/get_deps_mock';
import { getSearchSourceMock } from '../components/editor/__tests__/get_search_service_mock';
import { getDepsMock, getSearchSourceMock } from '../test_utils';

const MockSearchSource = getSearchSourceMock();
const deps = getDepsMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import { rangeControlFactory } from './range_control_factory';
import { ControlParams, CONTROL_TYPES } from '../editor_utils';
import { getSearchSourceMock } from '../components/editor/__tests__/get_search_service_mock';
import { getDepsMock } from '../components/editor/__tests__/get_deps_mock';
import { getDepsMock, getSearchSourceMock } from '../test_utils';

const deps = getDepsMock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import React from 'react';
import { FieldList } from 'src/plugins/data/public';
import { InputControlVisDependencies } from '../../../plugin';
import { InputControlVisDependencies } from '../plugin';

const fields: FieldList = [] as any;
fields.push({ name: 'myField' } as any);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { IIndexPattern } from '../../../../../../../plugins/data/public';
import { IIndexPattern } from 'src/plugins/data/public';

/**
* Returns forced **Partial** IndexPattern for use in tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { SearchSource } from '../../../legacy_imports';
import { SearchSource } from '../legacy_imports';

export const getSearchSourceMock = (esSearchResponse?: any): SearchSource =>
jest.fn().mockImplementation(() => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export { getDepsMock } from './get_deps_mock';
export { getIndexPatternMock } from './get_index_pattern_mock';
export { getIndexPatternsMock } from './get_index_patterns_mock';
export { getSearchSourceMock } from './get_search_service_mock';
export { updateComponent } from './update_component';

0 comments on commit ed04b17

Please sign in to comment.