Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import { HelloWorldAction, SayHelloAction, EmptyEmbeddable } from '../test_samples/index';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import {
FilterableEmbeddable,
FilterableEmbeddableFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';

import * as Rx from 'rxjs';
import { skip } from 'rxjs/operators';
Expand Down Expand Up @@ -47,6 +46,8 @@ import { ERROR_EMBEDDABLE_TYPE } from '../embeddables/error_embeddable';
import { Filter, FilterStateStore } from '@kbn/es-query';
import { PanelNotFoundError } from './panel_not_found_error';

jest.mock('ui/new_platform');

const embeddableFactories = new Map<string, EmbeddableFactory>();
embeddableFactories.set(FILTERABLE_EMBEDDABLE, new FilterableEmbeddableFactory());
embeddableFactories.set(CONTACT_CARD_EMBEDDABLE, new SlowContactCardEmbeddableFactory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import {
ContactCardEmbeddable,
ContactCardEmbeddableInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* eslint-disable max-classes-per-file */

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import { skip } from 'rxjs/operators';
import { ContactCardEmbeddable, FilterableEmbeddable } from '../test_samples/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import './ui_capabilities.test.mocks';
import '../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import {
HelloWorldAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';

import React from 'react';

Expand Down Expand Up @@ -48,6 +47,8 @@ import { CONTEXT_MENU_TRIGGER } from '../triggers';
import { attachAction } from '../triggers/attach_action';
import { EmbeddableFactory } from '../embeddables';

jest.mock('ui/new_platform');

const editModeAction = new EditModeAction();
actionRegistry.set(editModeAction.id, editModeAction);
attachAction(triggerRegistry, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../../../../ui_capabilities.test.mocks';
import '../../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import {
FilterableContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* under the License.
*/
import '../../../../ui_capabilities.test.mocks';
import { coreStartMock } from '../../../../../../../../core/public/ui_new_platform.test.mocks';
import { npStart } from 'ui/new_platform';

jest.mock('ui/new_platform', () =>
require('ui/new_platform/__mocks__/helpers').createUiNewPlatformMock()
);

import React from 'react';
import {
Expand Down Expand Up @@ -79,8 +83,8 @@ test('create new calls factory.adds a panel to the container', async done => {

await nextTick();

const overlayMock = coreStartMock.overlays;
((overlayMock.openModal.mock.calls[0][0] as any).props as ContactCardInitializerProps).onCreate({
const overlayMock = npStart.core.overlays;
((overlayMock.openModal as any).mock.calls[0][0].props as ContactCardInitializerProps).onCreate({
firstName: 'Dany',
lastName: 'Targaryan',
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../../../../ui_capabilities.test.mocks';
import '../../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import {
CONTACT_CARD_EMBEDDABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import '../../../../ui_capabilities.test.mocks';
import '../../../../../../../../core/public/ui_new_platform.test.mocks';

import React from 'react';
import {
Expand All @@ -37,6 +36,8 @@ import { Container, isErrorEmbeddable } from '../../../..';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { EmbeddableFactory } from '../../../../embeddables';

jest.mock('ui/new_platform');

let container: Container;
let embeddable: ContactCardEmbeddable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../../../ui_capabilities.test.mocks';
import '../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import { EmbeddableInput } from '../../../embeddables/i_embeddable';
import { Embeddable } from '../../../embeddables/embeddable';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import '../../../ui_capabilities.test.mocks';
import '../../../../../../../core/public/ui_new_platform.test.mocks';

jest.mock('ui/inspector', () => ({
Inspector: {
Expand Down Expand Up @@ -46,6 +45,8 @@ import { Inspector, Adapters } from 'ui/inspector';
import { EmbeddableFactory } from '../../../embeddables';
import { Filter, FilterStateStore } from '@kbn/es-query';

jest.mock('ui/new_platform');

const embeddableFactories = new Map<string, EmbeddableFactory>();
embeddableFactories.set(FILTERABLE_EMBEDDABLE, new FilterableEmbeddableFactory());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import '../../../ui_capabilities.test.mocks';
import '../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');

import {
FilterableContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';

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

Expand All @@ -33,6 +32,8 @@ import { Action, ActionContext, actionRegistry } from '../actions';
import { executeTriggerActions } from './execute_trigger_actions';
import { ContactCardEmbeddable } from '../test_samples';

jest.mock('ui/new_platform');

class TestAction extends Action {
public readonly type = 'testAction';
public checkCompatibility: (context: ActionContext) => boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
*/

import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';

import { triggerRegistry } from '../triggers';
import { HELLO_WORLD_ACTION_ID } from '../test_samples';
import { attachAction } from './attach_action';
import { detachAction } from './detach_action';

jest.mock('ui/new_platform');

beforeAll(() => {
triggerRegistry.clear();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
* under the License.
*/

jest.mock('ui/new_platform');
import { functionWrapper } from '../../interpreter/test_helpers';
import { inputControlVis } from './input_control_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());

describe('interpreter/functions#input_control_vis', () => {
const fn = functionWrapper(inputControlVis);
const visConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { kibanaPie } from './pie_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());
jest.mock('ui/new_platform');

const mockResponseHandler = jest.fn().mockReturnValue(Promise.resolve({
hits: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { metric } from './metric_vis_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());
jest.mock('ui/new_platform');

describe('interpreter/functions#metric', () => {
const fn = functionWrapper(metric);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { regionmap } from './region_map_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());
jest.mock('ui/new_platform');

describe('interpreter/functions#regionmap', () => {
const fn = functionWrapper(regionmap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { kibanaTable } from './table_vis_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());
jest.mock('ui/new_platform');

const mockResponseHandler = jest.fn().mockReturnValue(Promise.resolve({
tables: [{ columns: [], rows: [] }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { tagcloud } from './tag_cloud_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());
jest.mock('ui/new_platform');

describe('interpreter/functions#tagcloud', () => {
const fn = functionWrapper(tagcloud);
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/tile_map/public/tilemap_fn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { tilemap } from './tilemap_fn';

jest.mock('ui/new_platform', () => require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor());
jest.mock('ui/new_platform');
jest.mock('ui/vis/map/convert_to_geojson', () => ({
convertToGeoJson: jest.fn().mockReturnValue({
featureCollection: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
import { functionWrapper } from '../../interpreter/test_helpers';
import { kibanaMarkdown } from './markdown_fn';

jest.mock('ui/new_platform', () =>
require('../../../ui/public/new_platform/index.test.mocks').mockNewPlatformBackdoor()
);
jest.mock('ui/new_platform');

describe('interpreter/functions#markdown', () => {
const fn = functionWrapper(kibanaMarkdown);
Expand Down
45 changes: 45 additions & 0 deletions src/legacy/ui/public/new_platform/__mocks__/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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.
*/

import { coreMock } from '../../../../../core/public/mocks';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { dataPluginMock } from '../../../../../plugins/data/public/mocks';

export const pluginsMock = {
createSetup: () => ({
data: dataPluginMock.createSetupContract(),
}),
createStart: () => ({
data: dataPluginMock.createStartContract(),
}),
};

export const createUiNewPlatformMock = () => {
const mock = {
npSetup: {
core: coreMock.createSetup(),
plugins: pluginsMock.createSetup(),
},
npStart: {
core: coreMock.createStart(),
plugins: pluginsMock.createStart(),
},
};
return mock;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
* under the License.
*/

import { coreMock } from './mocks';
import { createUiNewPlatformMock } from './helpers';

export const coreSetupMock = coreMock.createSetup();
export const coreStartMock = coreMock.createStart();

jest.doMock('ui/new_platform', () => {
return {
npStart: { core: coreStartMock },
npSetup: { core: coreSetupMock },
};
});
const { npSetup, npStart } = createUiNewPlatformMock();
export { npSetup, npStart };
Loading