Use __mocks__ new_platform

This commit is contained in:
Rudolf Meijering 2019-06-25 10:06:34 +02:00
parent 4f5331c769
commit 2d666facc8
21 changed files with 27 additions and 50 deletions

View file

@ -140,13 +140,11 @@ module.exports = {
'src/core/public/**/*',
'!src/core/public/index.ts',
'!src/core/public/mocks.ts',
'!src/core/public/*.test.mocks.ts',
'!src/core/public/utils/**/*',
'src/core/server/**/*',
'!src/core/server/index.ts',
'!src/core/server/mocks.ts',
'!src/core/server/*.test.mocks.ts',
'src/plugins/**/public/**/*',
'!src/plugins/**/public/index*',

View file

@ -1,30 +0,0 @@
/*
* 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 './mocks';
export const coreSetupMock = coreMock.createSetup();
export const coreStartMock = coreMock.createStart();
jest.doMock('ui/new_platform', () => {
return {
npStart: { core: coreStartMock },
npSetup: { core: coreSetupMock },
};
});

View file

@ -35,6 +35,7 @@
*/
jest.mock('ui/metadata');
jest.mock('ui/new_platform');
jest.mock('ui/documentation_links/documentation_links');
jest.mock('ui/chrome');

View file

@ -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';

View file

@ -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,

View file

@ -18,7 +18,7 @@
*/
import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import * as Rx from 'rxjs';
import { skip } from 'rxjs/operators';

View file

@ -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,

View file

@ -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';

View file

@ -18,6 +18,7 @@
*/
import './ui_capabilities.test.mocks';
jest.mock('ui/new_platform');
import {
HelloWorldAction,

View file

@ -18,7 +18,7 @@
*/
import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import React from 'react';

View file

@ -18,7 +18,7 @@
*/
import '../../../../ui_capabilities.test.mocks';
import '../../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import {
FilterableContainer,

View file

@ -17,7 +17,7 @@
* under the License.
*/
import '../../../../ui_capabilities.test.mocks';
import { coreStartMock } from '../../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import React from 'react';
import {
@ -36,6 +36,8 @@ import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
import { skip } from 'rxjs/operators';
import * as Rx from 'rxjs';
import { EmbeddableFactory } from '../../../../embeddables';
import { OverlayStart } from 'src/core/public';
import { npStart } from 'ui/new_platform';
const onClose = jest.fn();
let container: Container;
@ -79,7 +81,8 @@ test('create new calls factory.adds a panel to the container', async done => {
await nextTick();
const overlayMock = coreStartMock.overlays;
const overlayMock = npStart.core.overlays as jest.Mocked<PublicMethodsOf<OverlayStart>>;
((overlayMock.openModal.mock.calls[0][0] as any).props as ContactCardInitializerProps).onCreate({
firstName: 'Dany',
lastName: 'Targaryan',

View file

@ -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,

View file

@ -18,7 +18,7 @@
*/
import '../../../../ui_capabilities.test.mocks';
import '../../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import React from 'react';
import {

View file

@ -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';

View file

@ -18,7 +18,7 @@
*/
import '../../../ui_capabilities.test.mocks';
import '../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
jest.mock('ui/inspector', () => ({
Inspector: {

View file

@ -18,7 +18,7 @@
*/
import '../../../ui_capabilities.test.mocks';
import '../../../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import {
FilterableContainer,

View file

@ -18,7 +18,7 @@
*/
import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import { EuiContextMenuPanelDescriptor } from '@elastic/eui';

View file

@ -18,7 +18,7 @@
*/
import '../ui_capabilities.test.mocks';
import '../../../../../core/public/ui_new_platform.test.mocks';
jest.mock('ui/new_platform');
import { triggerRegistry } from '../triggers';
import { HELLO_WORLD_ACTION_ID } from '../test_samples';

View file

@ -16,4 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
export { __setup__, __start__, npSetup, npStart } from './new_platform';
import { coreMock } from '../../../../core/public/mocks';
export const npStart = { core: coreMock.createStart() };
export const npSetup = { core: coreMock.createSetup() };

View file

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { InternalCoreSetup, InternalCoreStart } from '../../../../core/public';
import { InternalCoreSetup, InternalCoreStart } from '../../../core/public';
export const npSetup = {
core: (null as unknown) as InternalCoreSetup,