Skip to content

Commit

Permalink
Test fixes and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Apr 3, 2020
1 parent 27da7b3 commit 7fe2f63
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

import React, { Fragment } from 'react';
import { getLayerWizards } from '../../../layers/layer_wizard_registry';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getLayerWizards } from '../../../../../../../plugins/maps/public/layers/layer_wizard_registry';
import { EuiTitle, EuiSpacer, EuiCard, EuiIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import _ from 'lodash';
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.
*/

jest.mock('../../../../components/metrics_editor', () => ({
jest.mock('../../../../../../../../plugins/maps/public/components/metric_editor', () => ({
MetricsEditor: () => {
return <div>mockMetricsEditor</div>;
},
Expand Down
9 changes: 6 additions & 3 deletions x-pack/legacy/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
* you may not use this file except in compliance with the Elastic License.
*/

import './layers/layer_wizard_registry';
import './layers/sources/source_registry';
import './layers/load_layer_wizards';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import '../../../../plugins/maps/public/layers/layer_wizard_registry';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import '../../../../plugins/maps/public/layers/sources/source_registry';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import '../../../../plugins/maps/public/layers/load_layer_wizards';

import { Plugin, CoreStart, CoreSetup } from 'src/core/public';
// @ts-ignore
Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/maps/public/selectors/map_selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
} from '../../../../../plugins/maps/public/reducers/util';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { InnerJoin } from '../../../../../plugins/maps/public/layers/joins/inner_join';
import { getSourceByType } from '../layers/sources/source_registry';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getSourceByType } from '../../../../../plugins/maps/public/layers/sources/source_registry';

function createLayerInstance(layerDescriptor, inspectorAdapters) {
const source = createSourceInstance(layerDescriptor.sourceDescriptor, inspectorAdapters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/

jest.mock('../layers/vector_layer', () => {});
jest.mock('../layers/blended_vector_layer', () => {});
jest.mock('../layers/heatmap_layer', () => {});
jest.mock('../layers/vector_tile_layer', () => {});
jest.mock('../layers/joins/inner_join', () => {});
jest.mock('../../../../../plugins/maps/public/layers/vector_layer', () => {});
jest.mock('../../../../../plugins/maps/public/layers/blended_vector_layer', () => {});
jest.mock('../../../../../plugins/maps/public/layers/heatmap_layer', () => {});
jest.mock('../../../../../plugins/maps/public/layers/vector_tile_layer', () => {});
jest.mock('../../../../../plugins/maps/public/layers/joins/inner_join', () => {});
jest.mock('../../../../../plugins/maps/public/reducers/non_serializable_instances', () => ({
getInspectorAdapters: () => {
return {};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 15 additions & 30 deletions x-pack/plugins/maps/public/meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,24 @@ import { getEMSClient } from './meta';

jest.mock('@elastic/ems-client');

jest.mock('ui/chrome', () => ({
getBasePath: () => {
return '<basepath>';
},
getInjected(key) {
if (key === 'proxyElasticMapsServiceInMaps') {
return false;
} else if (key === 'isEmsEnabled') {
return true;
} else if (key === 'emsFileApiUrl') {
return 'https://file-api';
} else if (key === 'emsTileApiUrl') {
return 'https://tile-api';
}
},
getUiSettingsClient: () => {
return {
get: () => {
return '';
},
describe('default use without proxy', () => {
beforeEach(() => {
require('./kibana_services').getInjectedVarFunc = () => key => {
if (key === 'proxyElasticMapsServiceInMaps') {
return false;
} else if (key === 'isEmsEnabled') {
return true;
} else if (key === 'emsFileApiUrl') {
return 'https://file-api';
} else if (key === 'emsTileApiUrl') {
return 'https://tile-api';
}
};
},
}));

jest.mock('./kibana_services', () => {
return {
getLicenseId() {
require('./kibana_services').getLicenseId = () => {
return 'foobarlicenseid';
},
};
});
};
});

describe('default use without proxy', () => {
it('should construct EMSClient with absolute file and tile API urls', async () => {
getEMSClient();
const mockEmsClientCall = EMSClient.mock.calls[0];
Expand Down

0 comments on commit 7fe2f63

Please sign in to comment.