Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] fix tile layer attibution text and attribution link validation errors #73160

Merged
merged 4 commits into from
Jul 24, 2020
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

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 @@ -19,7 +19,12 @@ export const tmsLayerWizardConfig: LayerWizard = {
}),
icon: 'grid',
renderWizard: ({ previewLayers }: RenderWizardArguments) => {
const onSourceConfigChange = (sourceConfig: XYZTMSSourceConfig) => {
const onSourceConfigChange = (sourceConfig: XYZTMSSourceConfig | null) => {
if (!sourceConfig) {
previewLayers([]);
return;
}

const layerDescriptor = TileLayer.createDescriptor({
sourceDescriptor: XYZTMSSource.createDescriptor(sourceConfig),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.
*/

import React from 'react';
import { shallow } from 'enzyme';
import { XYZTMSEditor } from './xyz_tms_editor';

const onSourceConfigChange = () => {};

test('should render', () => {
const component = shallow(<XYZTMSEditor onSourceConfigChange={onSourceConfigChange} />);
expect(component).toMatchSnapshot();
});

describe('attribution validation', () => {
test('should provide validation error when attribution text is provided without attribution url', () => {
const component = shallow(<XYZTMSEditor onSourceConfigChange={onSourceConfigChange} />);
component.setState({ attributionText: 'myAttribtionLabel' });
expect(component).toMatchSnapshot();
});

test('should provide validation error when attribution url is provided without attribution text', () => {
const component = shallow(<XYZTMSEditor onSourceConfigChange={onSourceConfigChange} />);
component.setState({ attributionUrl: 'http://mySource' });
expect(component).toMatchSnapshot();
});

test('should provide no validation errors when attribution text and attribution url are provided', () => {
const component = shallow(<XYZTMSEditor onSourceConfigChange={onSourceConfigChange} />);
component.setState({ attributionText: 'myAttribtionLabel' });
component.setState({ attributionUrl: 'http://mySource' });
expect(component).toMatchSnapshot();
});
});
Loading