Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Jun 25, 2020
1 parent c99ccb2 commit aaf17fd
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 13 deletions.

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

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function createEsChoroplethLayerDescriptor({
geoField: leftGeoField,
scalingType: SCALING_TYPES.LIMIT,
tooltipProperties: [leftJoinField],
applyGlobalQuery: false,
}),
leftField: leftJoinField,
rightIndexPatternId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

jest.mock('../../../kibana_services', () => {
const MockIndexPatternSelect = (props: unknown) => {
return <div />;
};
return {
getIndexPatternSelectComponent: () => {
return MockIndexPatternSelect;
},
};
});

import React from 'react';
import { shallow } from 'enzyme';
import { BOUNDARIES_SOURCE, LayerTemplate } from './layer_template';

const renderWizardArguments = {
previewLayers: () => {},
mapColors: [],
isIndexingTriggered: false,
onRemove: () => {},
onIndexReady: () => {},
importSuccessHandler: () => {},
importErrorHandler: () => {},
};

test('should render elasticsearch UI when left source is BOUNDARIES_SOURCE.ELASTICSEARCH', async () => {
const component = shallow(<LayerTemplate {...renderWizardArguments} />);
component.setState({ leftSource: BOUNDARIES_SOURCE.ELASTICSEARCH });
expect(component).toMatchSnapshot();
});

test('should render EMS UI when left source is BOUNDARIES_SOURCE.EMS', async () => {
const component = shallow(<LayerTemplate {...renderWizardArguments} />);
component.setState({ leftSource: BOUNDARIES_SOURCE.EMS });
expect(component).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,24 @@ export class LayerTemplate extends Component<RenderWizardArguments, State> {
return;
}

const fields = emsFileLayer.getFieldsInLanguage();
this.setState({
leftEmsFields: fields
.filter((field) => {
return field.type === 'id';
})
.map((field) => {
return {
value: field.name,
label: field.description,
};
}),
});
const leftEmsFields = emsFileLayer
.getFieldsInLanguage()
.filter((field) => {
return field.type === 'id';
})
.map((field) => {
return {
value: field.name,
label: field.description,
};
});
this.setState(
{
leftEmsFields,
leftJoinField: leftEmsFields.length ? leftEmsFields[0].value : null,
},
this._previewLayer
);
};

_onLeftSourceChange = (optionId: string) => {
Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

jest.mock('../kibana_services', () => {
const MockIndexPatternSelect = (props: unknown) => {
return <div />;
};
const MockHttp = {
basePath: {
prepend: (path: string) => {
return `abc/${path}`;
},
},
};
return {
getIndexPatternSelectComponent: () => {
return MockIndexPatternSelect;
},
getHttp: () => {
return MockHttp;
},
};
});

import React from 'react';
import { shallow } from 'enzyme';
import { GeoIndexPatternSelect } from './geo_index_pattern_select';

test('should render', async () => {
const component = shallow(<GeoIndexPatternSelect onChange={() => {}} value={'indexPatternId'} />);

expect(component).toMatchSnapshot();
});

test('should render no index pattern warning when there are no matching index patterns', async () => {
const component = shallow(<GeoIndexPatternSelect onChange={() => {}} value={'indexPatternId'} />);
component.setState({ noGeoIndexPatternsExist: true });
expect(component).toMatchSnapshot();
});

0 comments on commit aaf17fd

Please sign in to comment.