Skip to content

Commit

Permalink
export deeply mocked keys
Browse files Browse the repository at this point in the history
  • Loading branch information
smith committed Oct 22, 2020
1 parent 93b0928 commit 3d39bc4
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/public/apm_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

jest.mock('@elastic/apm-rum');
import { init, apm } from '@elastic/apm-rum';
import { DeeplyMockedKeys } from '../typings';
import { ApmSystem } from './apm_system';

const initMock = init as jest.Mocked<typeof init>;
Expand Down
1 change: 1 addition & 0 deletions src/core/public/chrome/chrome_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import { BehaviorSubject } from 'rxjs';
import type { PublicMethodsOf } from '@kbn/utility-types';
import { DeeplyMockedKeys } from '../../typings';
import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './';

const createStartContractMock = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { MockedKeys } from '../../typings';
import {
NotificationsService,
NotificationsSetup,
Expand Down
1 change: 1 addition & 0 deletions src/core/public/overlays/overlay_service.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import type { PublicMethodsOf } from '@kbn/utility-types';
import { DeeplyMockedKeys } from '../../typings';
import { OverlayService, OverlayStart } from './overlay_service';
import { overlayBannersServiceMock } from './banners/banners_service.mock';
import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock';
Expand Down
1 change: 1 addition & 0 deletions src/core/server/core_context.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { REPO_ROOT } from '@kbn/dev-utils';
import { DeeplyMockedKeys } from '../typings';
import { CoreContext } from './core_context';
import { Env, IConfigService } from './config';
import { configServiceMock, getEnvOptions } from './config/mocks';
Expand Down
1 change: 1 addition & 0 deletions src/core/server/elasticsearch/client/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import { Client, ApiResponse } from '@elastic/elasticsearch';
import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport';
import { DeeplyMockedKeys } from '../../../typings';
import { ElasticsearchClient } from './types';
import { ICustomClusterClient } from './cluster_client';

Expand Down
1 change: 1 addition & 0 deletions src/core/server/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { of } from 'rxjs';
import { duration } from 'moment';
import { ByteSizeValue } from '@kbn/config-schema';
import { MockedKeys } from '../typings';
import { PluginInitializerContext, CoreSetup, CoreStart, StartServicesAccessor } from '.';
import { loggingSystemMock } from './logging/logging_system.mock';
import { loggingServiceMock } from './logging/logging_service.mock';
Expand Down
4 changes: 2 additions & 2 deletions src/core/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

type DeeplyMockedKeys<T> = {
export type DeeplyMockedKeys<T> = {
[P in keyof T]: T[P] extends (...args: any[]) => any
? jest.MockInstance<ReturnType<T[P]>, Parameters<T[P]>>
: DeeplyMockedKeys<T[P]>;
} &
T;

type MockedKeys<T> = { [P in keyof T]: jest.Mocked<T[P]> };
export type MockedKeys<T> = { [P in keyof T]: jest.Mocked<T[P]> };

0 comments on commit 3d39bc4

Please sign in to comment.