Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Fix prop fail in MetricVisValue (elastic#19991) (elastic#20041)
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes authored Jun 19, 2018
1 parent edb6b8d commit eecfe55
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MetricVisValue extends Component {
</div>
);

if (this.onClick) {
if (hasFilter) {
return (<EuiKeyboardAccessible>{metricComponent}</EuiKeyboardAccessible>);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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 { shallow } from 'enzyme';

import { MetricVisValue } from './metric_vis_value';

describe('MetricVisValue', () => {
it('should be wrapped in EuiKeyboardAccessible if having a click listener', () => {
const component = shallow(
<MetricVisValue
fontSize={12}
metric={{ label: 'Foo', value: 'foo' }}
onFilter={() => {}}
/>
);
expect(component.find('EuiKeyboardAccessible').exists()).toBe(true);
});

it('should not be wrapped in EuiKeyboardAccessible without having a click listener', () => {
const component = shallow(
<MetricVisValue
fontSize={12}
metric={{ label: 'Foo', value: 'foo' }}
/>
);
expect(component.find('EuiKeyboardAccessible').exists()).toBe(false);
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class MetricVisComponent extends Component {
key={index}
metric={metric}
fontSize={this.props.vis.params.metric.style.fontSize}
onFilter={metric.filterKey ? this._filterBucket : null}
onFilter={metric.filterKey && metric.bucketAgg ? this._filterBucket : null}
showLabel={this.props.vis.params.metric.labels.show}
/>
);
Expand Down

0 comments on commit eecfe55

Please sign in to comment.