mirror of
https://github.com/apache/superset.git
synced 2026-07-27 17:12:36 +00:00
- Add transformSeries unit tests for the symbolSizeFn / markerSize fallback - Extract duplicated getControl/mockControls helpers from five Timeseries controlPanel test files into the shared test helpers module Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
72 lines
2.6 KiB
TypeScript
72 lines
2.6 KiB
TypeScript
/**
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
* or more contributor license agreements. See the NOTICE file
|
|
* distributed with this work for additional information
|
|
* regarding copyright ownership. The ASF 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 { GenericDataType } from '@apache-superset/core/common';
|
|
import controlPanel from '../../../src/Timeseries/Step/controlPanel';
|
|
import { getControl, mockControls } from '../helpers';
|
|
|
|
const config = controlPanel;
|
|
|
|
const timeFormatControl = getControl(config, 'x_axis_time_format')!;
|
|
const numberFormatControl = getControl(config, 'x_axis_number_format')!;
|
|
|
|
test('should include x_axis_time_format control', () => {
|
|
expect(timeFormatControl).toBeDefined();
|
|
expect(timeFormatControl.config.default).toBe('smart_date');
|
|
});
|
|
|
|
test('should include x_axis_number_format control', () => {
|
|
expect(numberFormatControl).toBeDefined();
|
|
expect(numberFormatControl.config.default).toBe('~g');
|
|
});
|
|
|
|
test('x_axis_time_format should be visible for temporal columns', () => {
|
|
const visibilityFn = timeFormatControl?.config?.visibility;
|
|
expect(visibilityFn(mockControls('date', GenericDataType.Temporal))).toBe(
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('x_axis_time_format should be hidden for numeric columns', () => {
|
|
const visibilityFn = timeFormatControl?.config?.visibility;
|
|
expect(visibilityFn(mockControls('year', GenericDataType.Numeric))).toBe(
|
|
false,
|
|
);
|
|
});
|
|
|
|
test('x_axis_number_format should be visible for numeric columns', () => {
|
|
const visibilityFn = numberFormatControl?.config?.visibility;
|
|
expect(visibilityFn(mockControls('year', GenericDataType.Numeric))).toBe(
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('x_axis_number_format should be hidden for temporal columns', () => {
|
|
const visibilityFn = numberFormatControl?.config?.visibility;
|
|
expect(visibilityFn(mockControls('date', GenericDataType.Temporal))).toBe(
|
|
false,
|
|
);
|
|
});
|
|
|
|
test('x_axis_number_format should be hidden for string columns', () => {
|
|
const visibilityFn = numberFormatControl?.config?.visibility;
|
|
expect(visibilityFn(mockControls('name', GenericDataType.String))).toBe(
|
|
false,
|
|
);
|
|
});
|