diff --git a/src/legacy/core_plugins/metrics/public/components/panel_config/gauge.test.js b/src/legacy/core_plugins/metrics/public/components/panel_config/gauge.test.js new file mode 100644 index 000000000000..3f4fc7b185d6 --- /dev/null +++ b/src/legacy/core_plugins/metrics/public/components/panel_config/gauge.test.js @@ -0,0 +1,58 @@ +/* + * 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 React from 'react'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; +jest.mock('plugins/data/setup', () => ({ + data: { + query: { + ui: jest.fn(), + }, + }, +})); +import { GaugePanelConfig } from './gauge'; + +describe('GaugePanelConfig', () => { + it('call switch tab onChange={handleChange}', () => { + const props = { + fields: {}, + model: {}, + onChange: jest.fn(), + }; + const wrapper = shallowWithIntl(); + + wrapper + .find('EuiTab') + .first() + .simulate('onClick'); + expect(props.onChange).toBeCalled(); + }); + + it('call onChange={handleChange}', () => { + const props = { + fields: {}, + model: {}, + onChange: jest.fn(), + }; + const wrapper = shallowWithIntl(); + + wrapper.simulate('onClick'); + expect(props.onChange).toBeCalled(); + }); +}); diff --git a/src/legacy/core_plugins/metrics/public/components/vis_types/gauge/series.test.js b/src/legacy/core_plugins/metrics/public/components/vis_types/gauge/series.test.js new file mode 100644 index 000000000000..68853db2deaa --- /dev/null +++ b/src/legacy/core_plugins/metrics/public/components/vis_types/gauge/series.test.js @@ -0,0 +1,62 @@ +/* + * 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 React from 'react'; +import { GaugeSeries } from './series'; +import { mountWithIntl } from 'test_utils/enzyme_helpers'; + +jest.mock('plugins/data/setup', () => ({ + data: { + query: { + ui: jest.fn(), + }, + }, +})); + +const defaultProps = { + disableAdd: true, + disableDelete: true, + dragHandleProps: {}, + toggleVisible: jest.fn(), + onAdd: jest.fn(), + onChange: jest.fn(), + onClone: jest.fn(), + onDelete: jest.fn(), +}; + +it('should disable add data', () => { + const wrapper = mountWithIntl(); + const props = wrapper.props(); + + expect(props.disableAdd).toBeTruthy(); +}); + +it('should disable delete data', () => { + const wrapper = mountWithIntl(); + const props = wrapper.props(); + expect(props.disableDelete).toBeTruthy(); +}); + +it('should call toggleVisible function', () => { + const wrapper = mountWithIntl(); + wrapper + .find('EuiButtonIcon') + .at(0) + .simulate('click'); + expect(defaultProps.toggleVisible).toBeCalled(); +});