mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
Allowing withVerification to remove all options if none are valid (#7652)
This commit is contained in:
@@ -44,7 +44,7 @@ const defaultProps = {
|
||||
|
||||
const VALID_METRIC = { metric_name: 'sum__value', expression: 'SUM(energy_usage.value)' };
|
||||
|
||||
function setup(overrides) {
|
||||
function setup(overrides, validMetric) {
|
||||
const onChange = sinon.spy();
|
||||
const props = {
|
||||
onChange,
|
||||
@@ -53,7 +53,7 @@ function setup(overrides) {
|
||||
};
|
||||
const VerifiedControl = withVerification(MetricsControl, 'metric_name', 'savedMetrics');
|
||||
const wrapper = shallow(<VerifiedControl {...props} />);
|
||||
fetchMock.mock('glob:*/valid_metrics*', `["${VALID_METRIC.metric_name}"]`);
|
||||
fetchMock.mock('glob:*/valid_metrics*', validMetric || `["${VALID_METRIC.metric_name}"]`);
|
||||
return { props, wrapper, onChange };
|
||||
}
|
||||
|
||||
@@ -103,4 +103,14 @@ describe('VerifiedMetricsControl', () => {
|
||||
fetchMock.reset();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
it('Returns no verified options if none are valid', () => {
|
||||
const { wrapper } = setup({}, []);
|
||||
setTimeout(() => {
|
||||
expect(fetchMock.calls(defaultProps.getEndpoint())).toHaveLength(1);
|
||||
const child = wrapper.find(MetricsControl);
|
||||
expect(child.props().savedMetrics).toEqual([]);
|
||||
fetchMock.reset();
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user