Skip to content

Commit

Permalink
Move enzyme & misc test helpers out of __mocks__/ and into new test_h…
Browse files Browse the repository at this point in the history
…elpers/

They're not technically mocks since nothing is being mocked, so we should move them into a test_helpers folder for specificity & organization
  • Loading branch information
cee-chen committed Jun 1, 2021
1 parent 8edb316 commit eaca116
Show file tree
Hide file tree
Showing 39 changed files with 107 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

export { mockHistory, mockLocation } from './react_router_history.mock';

export { mockKibanaValues } from './kibana_logic.mock';
export { mockLicensingValues } from './licensing_logic.mock';
export { mockHttpValues } from './http_logic.mock';
Expand All @@ -23,10 +24,4 @@ export {
LogicMounter,
} from './kea.mock';

export { mountAsync } from './mount_async.mock';
export { mountWithIntl } from './mount_with_i18n.mock';
export { shallowWithIntl } from './shallow_with_i18n.mock';
export { rerender } from './enzyme_rerender.mock';
// Note: shallow_useeffect must be imported directly as a file

export { expectedAsyncError } from './expected_async_error';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import '../../../__mocks__/shallow_useeffect.mock';
import '../../../__mocks__/react_router_history.mock';
import { mockKibanaValues, setMockValues, setMockActions, rerender } from '../../../__mocks__';
import { mockKibanaValues, setMockValues, setMockActions } from '../../../__mocks__';

import React from 'react';
import { useParams } from 'react-router-dom';
Expand All @@ -16,6 +16,7 @@ import { shallow } from 'enzyme';

import { FlashMessages } from '../../../shared/flash_messages';
import { Loading } from '../../../shared/loading';
import { rerender } from '../../../test_helpers';
import { LogRetentionCallout } from '../log_retention';

import { AnalyticsLayout } from './analytics_layout';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* 2.0.
*/

import { mountWithIntl } from '../../../../../__mocks__';
import '../../../../../__mocks__/kea.mock';
import '../../../../__mocks__/engine_logic.mock';

import React from 'react';

import { EuiBasicTable, EuiBadge, EuiEmptyPrompt } from '@elastic/eui';

import { mountWithIntl } from '../../../../../test_helpers';

import { runActionColumnTests } from './test_helpers/shared_columns_tests';

import { AnalyticsTable } from './';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* 2.0.
*/

import { mountWithIntl } from '../../../../../__mocks__';
import '../../../../../__mocks__/kea.mock';
import '../../../../__mocks__/engine_logic.mock';

import React from 'react';

import { EuiBasicTable, EuiLink, EuiBadge, EuiEmptyPrompt } from '@elastic/eui';

import { mountWithIntl } from '../../../../../test_helpers';

import { QueryClicksTable } from './';

describe('QueryClicksTable', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* 2.0.
*/

import { mountWithIntl } from '../../../../../__mocks__';
import '../../../../../__mocks__/kea.mock';
import '../../../../__mocks__/engine_logic.mock';

import React from 'react';

import { EuiBasicTable, EuiBadge, EuiEmptyPrompt } from '@elastic/eui';

import { mountWithIntl } from '../../../../../test_helpers';

import { runActionColumnTests } from './test_helpers/shared_columns_tests';

import { RecentQueriesTable } from './';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { setMockValues, setMockActions, rerender } from '../../../__mocks__';
import { setMockValues, setMockActions } from '../../../__mocks__';
import '../../../__mocks__/shallow_useeffect.mock';
import '../../__mocks__/engine_logic.mock';

Expand All @@ -16,6 +16,7 @@ import { shallow } from 'enzyme';
import { EuiPageHeader } from '@elastic/eui';

import { Loading } from '../../../shared/loading';
import { rerender } from '../../../test_helpers';
import { LogRetentionCallout, LogRetentionTooltip } from '../log_retention';

import { ApiLogsTable, NewApiEventsPrompt } from './components';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { setMockValues, setMockActions, mountWithIntl } from '../../../../__mocks__';
import { setMockValues, setMockActions } from '../../../../__mocks__';

// NOTE: We're mocking FormattedRelative here because it (currently) has
// console warn issues, and it allows us to skip mocking dates
Expand All @@ -21,6 +21,7 @@ import { shallow } from 'enzyme';
import { EuiBasicTable, EuiBadge, EuiHealth, EuiButtonEmpty, EuiEmptyPrompt } from '@elastic/eui';

import { DEFAULT_META } from '../../../../shared/constants';
import { mountWithIntl } from '../../../../test_helpers';

import { ApiLogsTable } from './';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* 2.0.
*/

import { setMockValues, setMockActions, rerender } from '../../../../../__mocks__';
import { setMockValues, setMockActions } from '../../../../../__mocks__';

import React from 'react';

import { shallow } from 'enzyme';

import { EuiRadio, EuiCheckbox } from '@elastic/eui';

import { rerender } from '../../../../../test_helpers';

import { FormKeyEngineAccess, EngineSelection } from './key_engine_access';

describe('FormKeyEngineAccess', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import '../../../../__mocks__/react_router_history.mock';
import '../../../../__mocks__/shallow_useeffect.mock';
import { setMockActions, setMockValues, rerender } from '../../../../__mocks__';
import { setMockActions, setMockValues } from '../../../../__mocks__';

import React from 'react';
import { useParams } from 'react-router-dom';
Expand All @@ -18,6 +18,7 @@ import { EuiPageHeader } from '@elastic/eui';

import { SetAppSearchChrome as SetPageChrome } from '../../../../shared/kibana_chrome';
import { Loading } from '../../../../shared/loading';
import { rerender } from '../../../../test_helpers';

jest.mock('./curation_logic', () => ({ CurationLogic: jest.fn() }));
import { CurationLogic } from './curation_logic';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
* 2.0.
*/

import {
mountWithIntl,
mockKibanaValues,
setMockActions,
setMockValues,
} from '../../../../__mocks__';
import { mockKibanaValues, setMockActions, setMockValues } from '../../../../__mocks__';
import '../../../__mocks__/engine_logic.mock';

import React from 'react';
Expand All @@ -20,6 +15,7 @@ import { shallow, ReactWrapper } from 'enzyme';
import { EuiPageHeader, EuiBasicTable } from '@elastic/eui';

import { Loading } from '../../../../shared/loading';
import { mountWithIntl } from '../../../../test_helpers';
import { EmptyState } from '../components';

import { Curations, CurationsTable } from './curations';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* 2.0.
*/

import { setMockValues, setMockActions, rerender } from '../../../../__mocks__';
import { setMockValues, setMockActions } from '../../../../__mocks__';

import React from 'react';

import { shallow } from 'enzyme';

import { EuiTextArea, EuiButtonEmpty, EuiButton } from '@elastic/eui';

import { rerender } from '../../../../test_helpers';

import { Errors } from '../creation_response_components';

import { PasteJsonText, FlyoutHeader, FlyoutBody, FlyoutFooter } from './paste_json_text';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* 2.0.
*/

import { setMockValues, setMockActions, rerender } from '../../../../__mocks__';
import { setMockValues, setMockActions } from '../../../../__mocks__';

import React from 'react';

import { shallow } from 'enzyme';

import { EuiFilePicker, EuiButtonEmpty, EuiButton } from '@elastic/eui';

import { rerender } from '../../../../test_helpers';

import { Errors } from '../creation_response_components';

import { UploadJsonFile, FlyoutHeader, FlyoutBody, FlyoutFooter } from './upload_json_file';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { setMockValues, rerender } from '../../../__mocks__';
import { setMockValues } from '../../../__mocks__';
import { mockEngineValues } from '../../__mocks__';

import React from 'react';
Expand All @@ -14,6 +14,8 @@ import { shallow } from 'enzyme';

import { EuiBadge, EuiIcon } from '@elastic/eui';

import { rerender } from '../../../test_helpers';

import { EngineNav } from './engine_nav';

describe('EngineNav', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { mountWithIntl, setMockValues } from '../../../../../__mocks__';
import { setMockValues } from '../../../../../__mocks__';
import '../../../../../__mocks__/enterprise_search_url.mock';
import './__mocks__/engines_logic.mock';

Expand All @@ -15,6 +15,8 @@ import { shallow } from 'enzyme';

import { EuiBasicTable } from '@elastic/eui';

import { mountWithIntl } from '../../../../../test_helpers';

import { EngineDetails } from '../../../engine/types';

import { EnginesTable } from './engines_table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { mountWithIntl, setMockValues } from '../../../../../__mocks__';
import { setMockValues } from '../../../../../__mocks__';
import '../../../../../__mocks__/enterprise_search_url.mock';
import './__mocks__/engines_logic.mock';

Expand All @@ -15,6 +15,8 @@ import { shallow } from 'enzyme';

import { EuiBasicTable } from '@elastic/eui';

import { mountWithIntl } from '../../../../../test_helpers';

import { EngineDetails } from '../../../engine/types';

import { MetaEnginesTable } from './meta_engines_table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* 2.0.
*/

import { mountWithIntl } from '../../../../../__mocks__';

import React from 'react';

import { shallow } from 'enzyme';

import { EuiBasicTable, EuiHealth } from '@elastic/eui';

import { mountWithIntl } from '../../../../../test_helpers';

import { EngineDetails } from '../../../engine/types';

import { MetaEnginesTableExpandedRow } from './meta_engines_table_expanded_row';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* 2.0.
*/

import { setMockValues, rerender } from '../../../../../../__mocks__';
import { setMockValues } from '../../../../../../__mocks__';
import '../__mocks__/engines_logic.mock';

import { ShallowWrapper } from 'enzyme';

import { EuiBasicTable, EuiButtonIcon } from '@elastic/eui';

import { rerender } from '../../../../../../test_helpers';

import { EnginesLogic } from '../../../../engines';

import * as engineLinkHelpers from '../engine_link_helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
*/

import '../../../__mocks__/shallow_useeffect.mock';
import { setMockValues, setMockActions, rerender } from '../../../__mocks__';
import { setMockValues, setMockActions } from '../../../__mocks__';

import React from 'react';

import { shallow, ShallowWrapper } from 'enzyme';

import { rerender } from '../../../test_helpers';

import { LoadingState, EmptyState } from './components';
import { EnginesTable } from './components/tables/engines_table';
import { MetaEnginesTable } from './components/tables/meta_engines_table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
*/

import '../../../../__mocks__/shallow_useeffect.mock';
import { setMockValues, setMockActions, mountWithIntl } from '../../../../__mocks__';
import { setMockValues, setMockActions } from '../../../../__mocks__';

import React from 'react';

import { shallow } from 'enzyme';

import { EuiCallOut, EuiLink } from '@elastic/eui';

import { LogRetentionOptions } from '../';
import { mountWithIntl } from '../../../../test_helpers';

import { LogRetentionOptions } from '../index';

import { LogRetentionCallout } from './';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
* 2.0.
*/

import { setMockValues, mountWithIntl } from '../../../../__mocks__';
import { setMockValues } from '../../../../__mocks__';

import React from 'react';

import { shallow } from 'enzyme';

import { mountWithIntl } from '../../../../test_helpers';

import { LogRetentionOptions } from '../types';

import { LogRetentionMessage } from './';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* 2.0.
*/

import { setMockActions, setMockValues, rerender } from '../../../__mocks__';
import { setMockActions, setMockValues } from '../../../__mocks__';
import '../../../__mocks__/shallow_useeffect.mock';

import React from 'react';

import { shallow } from 'enzyme';

import { rerender } from '../../../test_helpers';

import { InputRow } from './input_row';

jest.mock('./multi_input_rows_logic', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
* 2.0.
*/

import { setMockValues, rerender } from '../../../__mocks__';
import { setMockValues } from '../../../__mocks__';
import '../../__mocks__/engine_logic.mock';

import React from 'react';
import { Route, Switch } from 'react-router-dom';

import { shallow } from 'enzyme';

import { rerender } from '../../../test_helpers';

import { ReindexJob } from './reindex_job';
import { Schema, MetaEngineSchema } from './views';

Expand Down
Loading

0 comments on commit eaca116

Please sign in to comment.