Skip to content

Commit

Permalink
[Refactor] Rename public/test_utils to public/__mocks__
Browse files Browse the repository at this point in the history
- to better follow/use jest setups and for .mock.ts suffixes
  • Loading branch information
cee-chen committed Jun 16, 2020
1 parent 7eaf62c commit 38010fc
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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.
*/

export { mockHistory } from './react_router_history.mock';
export { mockKibanaContext } from './kibana_context.mock';
export { mountWithKibanaContext } from './mount_with_context.mock';

// Note: shallow_usecontext must be imported directly as a file
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import { mount } from 'enzyme';

import { KibanaContext } from '../';
import { mockKibanaContext } from './mock_kibana_context';
import { mockKibanaContext } from './kibana_context.mock';

/**
* This helper mounts a component with a set of default KibanaContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* NOTE: This variable name MUST start with 'mock*' in order for
* Jest to accept its use within a jest.mock()
*/
import { mockKibanaContext } from './mock_kibana_context';
import { mockKibanaContext } from './kibana_context.mock';

jest.mock('react', () => ({
...jest.requireActual('react'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../test_utils/mock_shallow_usecontext';
import '../../../__mocks__/shallow_usecontext.mock';

import React from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../test_utils/mock_rr_usehistory';
import '../../../__mocks__/react_router_history.mock';

import React from 'react';
import { act } from 'react-dom/test-utils';
import { render } from 'enzyme';

import { KibanaContext } from '../../../';
import { mountWithKibanaContext, mockKibanaContext } from '../../../test_utils';
import { mountWithKibanaContext, mockKibanaContext } from '../../../__mocks__';

import { EmptyState, ErrorState, NoUserState } from '../empty_states';
import { EngineTable } from './engine_table';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import { EuiBasicTable, EuiPagination, EuiButtonEmpty, EuiLink } from '@elastic/eui';

import { mountWithKibanaContext } from '../../../test_utils';
import { mountWithKibanaContext } from '../../../__mocks__';
jest.mock('../../../shared/telemetry', () => ({ sendTelemetry: jest.fn() }));
import { sendTelemetry } from '../../../shared/telemetry';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../../../test_utils/mock_shallow_usecontext';
import '../../../__mocks__/shallow_usecontext.mock';

import React, { useContext } from 'react';
import { shallow } from 'enzyme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import '../test_utils/mock_shallow_usecontext';
import '../__mocks__/shallow_usecontext.mock';

import React, { useContext } from 'react';
import { Redirect } from 'react-router-dom';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { generateBreadcrumb } from './generate_breadcrumbs';
import { appSearchBreadcrumbs, enterpriseSearchBreadcrumbs } from './';

import { mockHistory } from '../../test_utils';
import { mockHistory } from '../../__mocks__';

jest.mock('../react_router_helpers', () => ({ letBrowserHandleEvent: jest.fn(() => false) }));
import { letBrowserHandleEvent } from '../react_router_helpers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import React from 'react';

import '../../test_utils/mock_rr_usehistory';
import { mountWithKibanaContext } from '../../test_utils';
import '../../__mocks__/react_router_history.mock';
import { mountWithKibanaContext } from '../../__mocks__';

jest.mock('./generate_breadcrumbs', () => ({ appSearchBreadcrumbs: jest.fn() }));
import { appSearchBreadcrumbs, SetAppSearchBreadcrumbs } from './';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import React from 'react';
import { shallow } from 'enzyme';
import { EuiLink, EuiButton } from '@elastic/eui';

import '../../test_utils/mock_rr_usehistory';
import { mockHistory } from '../../test_utils';
import '../../__mocks__/react_router_history.mock';
import { mockHistory } from '../../__mocks__';

import { EuiReactRouterLink, EuiReactRouterButton } from './eui_link';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';

import { httpServiceMock } from 'src/core/public/mocks';
import { mountWithKibanaContext } from '../../test_utils';
import { mountWithKibanaContext } from '../../__mocks__';
import { sendTelemetry, SendAppSearchTelemetry } from './';

describe('Shared Telemetry Helpers', () => {
Expand Down

This file was deleted.

0 comments on commit 38010fc

Please sign in to comment.