mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
test(frontend): Migrate from describe/it to flat test() pattern (#35305)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
import { render, screen } from '@superset-ui/core/spec';
|
||||
import LeftCell from './LeftCell';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('LeftCell', () => {
|
||||
test('should render column label for column row type', () => {
|
||||
const columnRow = {
|
||||
|
||||
@@ -26,6 +26,7 @@ const mockEntries = [
|
||||
{ time: '2023-01-04', sales: 400 },
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('Sparkline', () => {
|
||||
test('should render basic sparkline without time ratio', () => {
|
||||
const column = {
|
||||
|
||||
@@ -31,6 +31,7 @@ const mockEntries = [
|
||||
{ time: '2023-01-01', sales: 100, price: 10 },
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('ValueCell', () => {
|
||||
test('should render simple value without special column type', () => {
|
||||
render(
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
import { controlPanel as controlPanelConfig } from './controlPanel';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('TimeTable Control Panel', () => {
|
||||
test('should have required control panel structure', () => {
|
||||
expect(controlPanelConfig).toBeDefined();
|
||||
|
||||
@@ -127,6 +127,7 @@ function createMockChartProps(
|
||||
return tableChartProps;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('TimeTable transformProps', () => {
|
||||
test('should transform props correctly for metric rows', () => {
|
||||
const props = createMockChartProps();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
import { colorFromBounds } from './colorUtils';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('colorFromBounds', () => {
|
||||
test('should return null when no bounds are provided', () => {
|
||||
expect(colorFromBounds(50)).toBeNull();
|
||||
|
||||
@@ -24,6 +24,7 @@ const mockData = {
|
||||
'2023-01-03': { sales: 300 },
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('processTimeTableData', () => {
|
||||
test('should convert data to sorted entries', () => {
|
||||
const result = processTimeTableData(mockData);
|
||||
|
||||
@@ -33,6 +33,7 @@ jest.mock('src/utils/sortNumericValues', () => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('sortNumberWithMixedTypes', () => {
|
||||
const createMockRow = (value: any) => ({
|
||||
values: {
|
||||
|
||||
@@ -32,6 +32,7 @@ const mockEntries = [
|
||||
{ time: '2023-01-04', sales: 400 },
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('sparklineDataUtils', () => {
|
||||
test('parseTimeRatio should parse string values', () => {
|
||||
expect(parseTimeRatio('5')).toBe(5);
|
||||
|
||||
@@ -24,7 +24,9 @@ import {
|
||||
transformChartData,
|
||||
} from './sparklineHelpers';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('sparklineHelpers', () => {
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('getSparklineTextWidth', () => {
|
||||
test('should return a positive number for text width', () => {
|
||||
const result = getSparklineTextWidth('123.45');
|
||||
@@ -39,6 +41,7 @@ describe('sparklineHelpers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('isValidBoundValue', () => {
|
||||
test('should return true for valid numbers', () => {
|
||||
expect(isValidBoundValue(0)).toBe(true);
|
||||
@@ -56,6 +59,7 @@ describe('sparklineHelpers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('getDataBounds', () => {
|
||||
test('should return correct min and max for valid data', () => {
|
||||
const data = [10, 5, 20, 15];
|
||||
@@ -90,6 +94,7 @@ describe('sparklineHelpers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('createYScaleConfig', () => {
|
||||
test('should use data bounds when no axis bounds provided', () => {
|
||||
const validData = [10, 20, 30];
|
||||
@@ -144,6 +149,7 @@ describe('sparklineHelpers', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('transformChartData', () => {
|
||||
test('should transform data with indices', () => {
|
||||
const data = [10, 20, 30];
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
} from './valueCalculations';
|
||||
import type { ColumnConfig, Entry } from '../../types';
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('valueCalculations', () => {
|
||||
const mockEntries: Entry[] = [
|
||||
{ time: '2023-01-03', sales: 300, price: 30 },
|
||||
@@ -32,6 +33,7 @@ describe('valueCalculations', () => {
|
||||
{ time: '2023-01-01', sales: 100, price: 10 },
|
||||
];
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('calculateTimeValue', () => {
|
||||
test('should calculate diff comparison correctly', () => {
|
||||
const column: ColumnConfig = {
|
||||
@@ -125,6 +127,7 @@ describe('valueCalculations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('calculateContribution', () => {
|
||||
test('should calculate contribution correctly', () => {
|
||||
const result = calculateContribution(300, mockEntries);
|
||||
@@ -152,6 +155,7 @@ describe('valueCalculations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('calculateAverage', () => {
|
||||
test('should calculate average correctly', () => {
|
||||
const column: ColumnConfig = {
|
||||
@@ -213,6 +217,7 @@ describe('valueCalculations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
|
||||
describe('calculateCellValue', () => {
|
||||
test('should route to time calculation', () => {
|
||||
const column: ColumnConfig = {
|
||||
|
||||
Reference in New Issue
Block a user