mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
refact(NA): migrate jest tests to the new pattern.
This commit is contained in:
parent
7482127344
commit
1a1d6d16aa
57 changed files with 93 additions and 38 deletions
|
@ -33,7 +33,7 @@ import {
|
|||
MockNotificationsService,
|
||||
mockNotificationStart,
|
||||
MockUiSettingsService,
|
||||
} from './core_system.mock';
|
||||
} from './core_system.test.mocks';
|
||||
|
||||
import { CoreSystem } from './core_system';
|
||||
jest.spyOn(CoreSystem.prototype, 'stop');
|
||||
|
|
|
@ -24,7 +24,7 @@ expect.addSnapshotSerializer({
|
|||
print: () => `Rx.Observable`,
|
||||
});
|
||||
|
||||
import { mockRender } from './fatal_errors_service.mock';
|
||||
import { mockRender } from './fatal_errors_service.test.mocks';
|
||||
|
||||
import { FatalErrorsService } from './fatal_errors_service';
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockReactDomRender, mockReactDomUnmount } from './toasts_service.mock';
|
||||
import { mockReactDomRender, mockReactDomUnmount } from './toasts_service.test.mocks';
|
||||
|
||||
import { ToastsService } from './toasts_service';
|
||||
import { ToastsStart } from './toasts_start';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { MockUiSettingsApi, MockUiSettingsClient } from './ui_settings_service.mock';
|
||||
import { MockUiSettingsApi, MockUiSettingsClient } from './ui_settings_service.test.mocks';
|
||||
|
||||
// Load the service
|
||||
import { UiSettingsService } from './ui_settings_service';
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
||||
jest.mock('../../../../package.json', () => mockPackage);
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { ObjectToConfigAdapter } from './object_to_config_adapter';
|
||||
|
|
21
src/core/server/config/config_service.test.mocks.ts
Normal file
21
src/core/server/config/config_service.test.mocks.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const mockPackage = new Proxy({ raw: {} as any }, { get: (obj, prop) => obj.raw[prop] });
|
||||
jest.mock('../../../../package.json', () => mockPackage);
|
|
@ -22,7 +22,7 @@
|
|||
import { BehaviorSubject } from 'rxjs';
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
import { mockPackage } from './config_service.mock';
|
||||
import { mockPackage } from './config_service.test.mocks';
|
||||
|
||||
import { schema, Type, TypeOf } from '@kbn/config-schema';
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockPackage } from './env.mock';
|
||||
import { mockPackage } from './env.test.mocks';
|
||||
|
||||
import { Env } from '.';
|
||||
import { getEnvOptions } from './__mocks__/env';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockGetConfigFromFiles } from './raw_config_service.mock';
|
||||
import { mockGetConfigFromFiles } from './raw_config_service.test.mocks';
|
||||
|
||||
import { first } from 'rxjs/operators';
|
||||
import { RawConfigService } from '.';
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
MockClient,
|
||||
mockParseElasticsearchClientConfig,
|
||||
MockScopedClusterClient,
|
||||
} from './cluster_client.mock';
|
||||
} from './cluster_client.test.mocks';
|
||||
|
||||
import { errors } from 'elasticsearch';
|
||||
import { get } from 'lodash';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockReadFileSync } from './elasticsearch_client_config.mock';
|
||||
import { mockReadFileSync } from './elasticsearch_client_config.test.mocks';
|
||||
|
||||
import { duration } from 'moment';
|
||||
import { loggingServiceMock } from '../logging/logging_service.mock';
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export const MockClusterClient = jest.fn();
|
||||
jest.mock('./cluster_client', () => ({ ClusterClient: MockClusterClient }));
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { ClusterClient } from './cluster_client';
|
||||
import { ElasticsearchConfig } from './elasticsearch_config';
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const MockClusterClient = jest.fn();
|
||||
jest.mock('./cluster_client', () => ({ ClusterClient: MockClusterClient }));
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { first } from 'rxjs/operators';
|
||||
|
||||
import { MockClusterClient } from './elasticsearch_service.mock';
|
||||
import { MockClusterClient } from './elasticsearch_service.test.mocks';
|
||||
|
||||
import { BehaviorSubject, combineLatest } from 'rxjs';
|
||||
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
|
||||
|
|
|
@ -17,12 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export const mockHttpServer = jest.fn();
|
||||
|
||||
jest.mock('./http_server', () => ({
|
||||
HttpServer: mockHttpServer,
|
||||
}));
|
||||
|
||||
import { Server, ServerOptions } from 'hapi';
|
||||
import { HttpService } from './http_service';
|
||||
|
||||
|
|
24
src/core/server/http/http_service.test.mocks.ts
Normal file
24
src/core/server/http/http_service.test.mocks.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export const mockHttpServer = jest.fn();
|
||||
|
||||
jest.mock('./http_server', () => ({
|
||||
HttpServer: mockHttpServer,
|
||||
}));
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockHttpServer } from './http_service.mock';
|
||||
import { mockHttpServer } from './http_service.test.mocks';
|
||||
|
||||
import { noop } from 'lodash';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
httpService,
|
||||
mockLegacyService,
|
||||
mockPluginsService,
|
||||
} from './index.mock';
|
||||
} from './index.test.mocks';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Server } from '.';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockCreateLayout } from './appenders.mock';
|
||||
import { mockCreateLayout } from './appenders.test.mocks';
|
||||
|
||||
import { LegacyAppender } from '../../legacy/logging/appenders/legacy_appender';
|
||||
import { Appenders } from './appenders';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockCreateWriteStream } from './file_appender.mock';
|
||||
import { mockCreateWriteStream } from './file_appender.test.mocks';
|
||||
|
||||
import { LogLevel } from '../../log_level';
|
||||
import { LogRecord } from '../../log_record';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockPackage, mockReaddir, mockReadFile, mockStat } from './plugin_discovery.mock';
|
||||
import { mockPackage, mockReaddir, mockReadFile, mockStat } from './plugin_discovery.test.mocks';
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { PluginDiscoveryErrorType } from './plugin_discovery_error';
|
||||
|
||||
import { mockReadFile } from './plugin_manifest_parser.mock';
|
||||
import { mockReadFile } from './plugin_manifest_parser.test.mocks';
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { parseManifest } from './plugin_manifest_parser';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockDiscover, mockPackage } from './plugins_service.mock';
|
||||
import { mockDiscover, mockPackage } from './plugins_service.test.mocks';
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { BehaviorSubject, from } from 'rxjs';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockCreatePluginStartContext } from './plugins_system.mock';
|
||||
import { mockCreatePluginStartContext } from './plugins_system.test.mocks';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { Config, ConfigService, Env, ObjectToConfigAdapter } from '../config';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { configService, logger, mockServer } from './index.mock';
|
||||
import { configService, logger, mockServer } from './index.test.mocks';
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { filter, first } from 'rxjs/operators';
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { mockMakeDirAsync, mockWriteFileAsync } from './integrate_locale_files.mock';
|
||||
import { mockMakeDirAsync, mockWriteFileAsync } from './integrate_locale_files.test.mocks';
|
||||
|
||||
import path from 'path';
|
||||
import { integrateLocaleFiles, verifyMessages } from './integrate_locale_files';
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
import React from 'react';
|
||||
import { mountWithIntl } from 'test_utils/enzyme_helpers';
|
||||
|
||||
import { settingsGet } from './new_vis_modal.mock';
|
||||
import { settingsGet } from './new_vis_modal.test.mocks';
|
||||
|
||||
import { NewVisModal } from './new_vis_modal';
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
mockGetAutocompleteSuggestions,
|
||||
mockPersistedLog,
|
||||
mockPersistedLogFactory,
|
||||
} from 'ui/query_bar/components/query_bar.mock';
|
||||
} from 'ui/query_bar/components/query_bar.test.mocks';
|
||||
|
||||
import { EuiFieldText } from '@elastic/eui';
|
||||
import React from 'react';
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { mockFatalError } from './subscribe_with_scope.mock';
|
||||
import { mockFatalError } from './subscribe_with_scope.test.mocks';
|
||||
|
||||
import * as Rx from 'rxjs';
|
||||
import { subscribeWithScope } from './subscribe_with_scope';
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { mockDataLoaderFetch, timefilter } from './embedded_visualize_handler.mock';
|
||||
import { mockDataLoaderFetch, timefilter } from './embedded_visualize_handler.test.mocks';
|
||||
|
||||
// @ts-ignore
|
||||
import MockState from '../../../../../fixtures/mock_state';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { mockJobQueueClient } from './report_info_button.mock';
|
||||
import { mockJobQueueClient } from './report_info_button.test.mocks';
|
||||
|
||||
import React from 'react';
|
||||
import { mountWithIntl } from 'test_utils/enzyme_helpers';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { mockClient } from './polling_service.mock';
|
||||
import { mockClient } from './polling_service.test.mocks';
|
||||
|
||||
import { ReindexStatus, ReindexStep } from '../../../../../../common/types';
|
||||
import { ReindexPollingService } from './polling_service';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import './file_integrity.mock';
|
||||
import './file_integrity.test.mocks';
|
||||
|
||||
import { getIntegrityHash, getIntegrityHashes } from './file_integrity';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue