chore(lint): migrate Jest lint rules from eslint to oxlint (#37787)

Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
Đỗ Trọng Hải
2026-02-08 16:44:42 +07:00
committed by GitHub
parent c4d2d42b3b
commit 563d9f1a3f
264 changed files with 1893 additions and 1952 deletions

View File

@@ -35,7 +35,7 @@ import {
} from '../../src/utils/annotation';
describe('formatAnnotationLabel', () => {
it('should handle default cases properly', () => {
test('should handle default cases properly', () => {
expect(formatAnnotationLabel('name')).toEqual('name');
expect(formatAnnotationLabel('name', 'title')).toEqual('name - title');
expect(formatAnnotationLabel('name', 'title', ['description'])).toEqual(
@@ -43,7 +43,7 @@ describe('formatAnnotationLabel', () => {
);
});
it('should handle missing cases properly', () => {
test('should handle missing cases properly', () => {
expect(formatAnnotationLabel()).toEqual('');
expect(formatAnnotationLabel(undefined, 'title')).toEqual('title');
expect(formatAnnotationLabel('name', undefined, ['description'])).toEqual(
@@ -54,7 +54,7 @@ describe('formatAnnotationLabel', () => {
).toEqual('description');
});
it('should handle multiple descriptions properly', () => {
test('should handle multiple descriptions properly', () => {
expect(
formatAnnotationLabel('name', 'title', [
'description 1',
@@ -71,7 +71,7 @@ describe('formatAnnotationLabel', () => {
});
describe('extractForecastSeriesContext', () => {
it('should extract the correct series name and type', () => {
test('should extract the correct series name and type', () => {
expect(parseAnnotationOpacity(AnnotationOpacity.Low)).toEqual(0.2);
expect(parseAnnotationOpacity(AnnotationOpacity.Medium)).toEqual(0.5);
expect(parseAnnotationOpacity(AnnotationOpacity.High)).toEqual(0.8);
@@ -81,7 +81,7 @@ describe('extractForecastSeriesContext', () => {
});
describe('extractAnnotationLabels', () => {
it('should extract all annotations that can be added to the legend', () => {
test('should extract all annotations that can be added to the legend', () => {
const layers: AnnotationLayer[] = [
{
annotationType: AnnotationType.Formula,
@@ -140,7 +140,7 @@ describe('evalFormula', () => {
value: 'x+1',
showLabel: true,
};
it('Should evaluate a regular formula', () => {
test('Should evaluate a regular formula', () => {
const data: TimeseriesDataRecord[] = [
{ __timestamp: 0 },
{ __timestamp: 10 },
@@ -152,7 +152,7 @@ describe('evalFormula', () => {
]);
});
it('Should evaluate a formula containing redundant characters', () => {
test('Should evaluate a formula containing redundant characters', () => {
const data: TimeseriesDataRecord[] = [
{ __timestamp: 0 },
{ __timestamp: 10 },
@@ -171,7 +171,7 @@ describe('evalFormula', () => {
]);
});
it('Should evaluate a formula if axis type is category', () => {
test('Should evaluate a formula if axis type is category', () => {
const data: DataRecord[] = [{ gender: 'boy' }, { gender: 'girl' }];
expect(

View File

@@ -19,14 +19,14 @@
import { parseAxisBound } from '../../src/utils/controls';
describe('parseYAxisBound', () => {
it('should return undefined for invalid values', () => {
test('should return undefined for invalid values', () => {
expect(parseAxisBound(null)).toBeUndefined();
expect(parseAxisBound(undefined)).toBeUndefined();
expect(parseAxisBound(NaN)).toBeUndefined();
expect(parseAxisBound('abc')).toBeUndefined();
});
it('should return numeric value for valid values', () => {
test('should return numeric value for valid values', () => {
expect(parseAxisBound(0)).toEqual(0);
expect(parseAxisBound('0')).toEqual(0);
expect(parseAxisBound(1)).toEqual(1);

View File

@@ -28,7 +28,7 @@ import {
import { ForecastSeriesEnum } from '../../src/types';
describe('extractForecastSeriesContext', () => {
it('should extract the correct series name and type', () => {
test('should extract the correct series name and type', () => {
expect(extractForecastSeriesContext('abcd')).toEqual({
name: 'abcd',
type: ForecastSeriesEnum.Observation,
@@ -49,7 +49,7 @@ describe('extractForecastSeriesContext', () => {
});
describe('reorderForecastSeries', () => {
it('should reorder the forecast series and preserve values', () => {
test('should reorder the forecast series and preserve values', () => {
const input: SeriesOption[] = [
{ id: `series${ForecastSeriesEnum.Observation}`, data: [10, 20, 30] },
{ id: `series${ForecastSeriesEnum.ForecastTrend}`, data: [15, 25, 35] },
@@ -65,16 +65,16 @@ describe('reorderForecastSeries', () => {
expect(reorderForecastSeries(input)).toEqual(expectedOutput);
});
it('should handle an empty array', () => {
test('should handle an empty array', () => {
expect(reorderForecastSeries([])).toEqual([]);
});
it('should not reorder if no relevant series are present', () => {
test('should not reorder if no relevant series are present', () => {
const input: SeriesOption[] = [{ id: 'some-other-series' }];
expect(reorderForecastSeries(input)).toEqual(input);
});
it('should handle undefined ids', () => {
test('should handle undefined ids', () => {
const input: SeriesOption[] = [
{ id: `series${ForecastSeriesEnum.ForecastLower}` },
{ id: undefined },
@@ -90,7 +90,7 @@ describe('reorderForecastSeries', () => {
});
describe('rebaseForecastDatum', () => {
it('should subtract lower confidence level from upper value', () => {
test('should subtract lower confidence level from upper value', () => {
expect(
rebaseForecastDatum([
{
@@ -146,7 +146,7 @@ describe('rebaseForecastDatum', () => {
]);
});
it('should rename all series based on verboseMap but leave __timestamp alone', () => {
test('should rename all series based on verboseMap but leave __timestamp alone', () => {
expect(
rebaseForecastDatum(
[

View File

@@ -21,15 +21,15 @@ import { getPercentFormatter } from '../../src/utils/formatters';
describe('getPercentFormatter', () => {
const value = 0.6;
it('should format as percent if no format is specified', () => {
test('should format as percent if no format is specified', () => {
expect(getPercentFormatter().format(value)).toEqual('60%');
});
it('should format as percent if SMART_NUMBER is specified', () => {
test('should format as percent if SMART_NUMBER is specified', () => {
expect(
getPercentFormatter(NumberFormats.SMART_NUMBER).format(value),
).toEqual('60%');
});
it('should format using a provided format', () => {
test('should format using a provided format', () => {
expect(
getPercentFormatter(NumberFormats.PERCENT_2_POINT).format(value),
).toEqual('60.00%');

View File

@@ -402,7 +402,7 @@ test('sortAndFilterSeries by name with numbers desc', () => {
});
describe('extractSeries', () => {
it('should generate a valid ECharts timeseries series object', () => {
test('should generate a valid ECharts timeseries series object', () => {
const data = [
{
__timestamp: '2000-01-01',
@@ -447,7 +447,7 @@ describe('extractSeries', () => {
]);
});
it('should remove rows that have a null x-value', () => {
test('should remove rows that have a null x-value', () => {
const data = [
{
x: 1,
@@ -493,7 +493,7 @@ describe('extractSeries', () => {
]);
});
it('should convert NULL x-values to NULL_STRING for categorical axis', () => {
test('should convert NULL x-values to NULL_STRING for categorical axis', () => {
const data = [
{
browser: 'Firefox',
@@ -530,7 +530,7 @@ describe('extractSeries', () => {
]);
});
it('should do missing value imputation', () => {
test('should do missing value imputation', () => {
const data = [
{
__timestamp: '2000-01-01',
@@ -602,7 +602,7 @@ describe('extractSeries', () => {
});
describe('extractGroupbyLabel', () => {
it('should join together multiple groupby labels', () => {
test('should join together multiple groupby labels', () => {
expect(
extractGroupbyLabel({
datum: { a: 'abc', b: 'qwerty' },
@@ -611,13 +611,13 @@ describe('extractGroupbyLabel', () => {
).toEqual('abc, qwerty');
});
it('should handle a single groupby', () => {
test('should handle a single groupby', () => {
expect(
extractGroupbyLabel({ datum: { xyz: 'qqq' }, groupby: ['xyz'] }),
).toEqual('qqq');
});
it('should handle mixed types', () => {
test('should handle mixed types', () => {
expect(
extractGroupbyLabel({
datum: { strcol: 'abc', intcol: 123, floatcol: 0.123, boolcol: true },
@@ -626,7 +626,7 @@ describe('extractGroupbyLabel', () => {
).toEqual('abc, 123, 0.123, true');
});
it('should handle null and undefined groupby', () => {
test('should handle null and undefined groupby', () => {
expect(
extractGroupbyLabel({
datum: { strcol: 'abc', intcol: 123, floatcol: 0.123, boolcol: true },
@@ -638,7 +638,7 @@ describe('extractGroupbyLabel', () => {
});
describe('extractShowValueIndexes', () => {
it('should return the latest index for stack', () => {
test('should return the latest index for stack', () => {
expect(
extractShowValueIndexes(
[
@@ -696,7 +696,7 @@ describe('extractShowValueIndexes', () => {
).toEqual([undefined, 1, 0, 1, undefined, 2, 1, 1, undefined, 1]);
});
it('should handle the negative numbers for total only', () => {
test('should handle the negative numbers for total only', () => {
expect(
extractShowValueIndexes(
[
@@ -758,40 +758,40 @@ describe('extractShowValueIndexes', () => {
describe('formatSeriesName', () => {
const numberFormatter = getNumberFormatter();
const timeFormatter = getTimeFormatter();
it('should handle missing values properly', () => {
test('should handle missing values properly', () => {
expect(formatSeriesName(undefined)).toEqual('<NULL>');
expect(formatSeriesName(null)).toEqual('<NULL>');
});
it('should handle string values properly', () => {
test('should handle string values properly', () => {
expect(formatSeriesName('abc XYZ!')).toEqual('abc XYZ!');
});
it('should handle boolean values properly', () => {
test('should handle boolean values properly', () => {
expect(formatSeriesName(true)).toEqual('true');
});
it('should use default formatting for numeric values without formatter', () => {
test('should use default formatting for numeric values without formatter', () => {
expect(formatSeriesName(12345678.9)).toEqual('12345678.9');
});
it('should use numberFormatter for numeric values when formatter is provided', () => {
test('should use numberFormatter for numeric values when formatter is provided', () => {
expect(formatSeriesName(12345678.9, { numberFormatter })).toEqual('12.3M');
});
it('should use default formatting for date values without formatter', () => {
test('should use default formatting for date values without formatter', () => {
expect(formatSeriesName(new Date('2020-09-11'))).toEqual(
'2020-09-11T00:00:00.000Z',
);
});
it('should use timeFormatter for date values when formatter is provided', () => {
test('should use timeFormatter for date values when formatter is provided', () => {
expect(formatSeriesName(new Date('2020-09-11'), { timeFormatter })).toEqual(
'2020-09-11 00:00:00',
);
});
it('should normalize non-UTC string based timestamp', () => {
test('should normalize non-UTC string based timestamp', () => {
const annualTimeFormatter = getTimeFormatter('%Y');
expect(
formatSeriesName('1995-01-01 00:00:00.000000', {
@@ -803,7 +803,7 @@ describe('formatSeriesName', () => {
});
describe('getLegendProps', () => {
it('should return the correct props for scroll type with top orientation without zoom', () => {
test('should return the correct props for scroll type with top orientation without zoom', () => {
expect(
getLegendProps(
LegendType.Scroll,
@@ -822,7 +822,7 @@ describe('getLegendProps', () => {
});
});
it('should return the correct props for scroll type with top orientation with zoom', () => {
test('should return the correct props for scroll type with top orientation with zoom', () => {
expect(
getLegendProps(
LegendType.Scroll,
@@ -841,7 +841,7 @@ describe('getLegendProps', () => {
});
});
it('should return the correct props for plain type with left orientation', () => {
test('should return the correct props for plain type with left orientation', () => {
expect(
getLegendProps(LegendType.Plain, LegendOrientation.Left, true, theme),
).toEqual({
@@ -853,7 +853,7 @@ describe('getLegendProps', () => {
});
});
it('should return the correct props for plain type with right orientation without zoom', () => {
test('should return the correct props for plain type with right orientation without zoom', () => {
expect(
getLegendProps(
LegendType.Plain,
@@ -872,7 +872,7 @@ describe('getLegendProps', () => {
});
});
it('should return the correct props for plain type with right orientation with zoom', () => {
test('should return the correct props for plain type with right orientation with zoom', () => {
expect(
getLegendProps(
LegendType.Plain,
@@ -891,7 +891,7 @@ describe('getLegendProps', () => {
});
});
it('should default plain legends to scroll for bottom orientation', () => {
test('should default plain legends to scroll for bottom orientation', () => {
expect(
getLegendProps(LegendType.Plain, LegendOrientation.Bottom, false, theme),
).toEqual({
@@ -903,7 +903,7 @@ describe('getLegendProps', () => {
});
});
it('should default plain legends to scroll for top orientation', () => {
test('should default plain legends to scroll for top orientation', () => {
expect(
getLegendProps(LegendType.Plain, LegendOrientation.Top, false, theme),
).toEqual({
@@ -918,7 +918,7 @@ describe('getLegendProps', () => {
});
describe('getChartPadding', () => {
it('should handle top default', () => {
test('should handle top default', () => {
expect(getChartPadding(true, LegendOrientation.Top)).toEqual({
bottom: 0,
left: 0,
@@ -927,7 +927,7 @@ describe('getChartPadding', () => {
});
});
it('should handle left default', () => {
test('should handle left default', () => {
expect(getChartPadding(true, LegendOrientation.Left)).toEqual({
bottom: 0,
left: defaultLegendPadding[LegendOrientation.Left],
@@ -936,7 +936,7 @@ describe('getChartPadding', () => {
});
});
it('should return the default padding when show is false', () => {
test('should return the default padding when show is false', () => {
expect(
getChartPadding(false, LegendOrientation.Left, 100, {
top: 10,
@@ -952,7 +952,7 @@ describe('getChartPadding', () => {
});
});
it('should return the correct padding for left orientation', () => {
test('should return the correct padding for left orientation', () => {
expect(getChartPadding(true, LegendOrientation.Left, 100)).toEqual({
bottom: 0,
left: 100,
@@ -969,7 +969,7 @@ describe('getChartPadding', () => {
});
});
it('should return the correct padding for right orientation', () => {
test('should return the correct padding for right orientation', () => {
expect(getChartPadding(true, LegendOrientation.Right, 50)).toEqual({
bottom: 0,
left: 0,
@@ -986,7 +986,7 @@ describe('getChartPadding', () => {
});
});
it('should return the correct padding for top orientation', () => {
test('should return the correct padding for top orientation', () => {
expect(getChartPadding(true, LegendOrientation.Top, 20)).toEqual({
bottom: 0,
left: 0,
@@ -1003,7 +1003,7 @@ describe('getChartPadding', () => {
});
});
it('should return the correct padding for bottom orientation', () => {
test('should return the correct padding for bottom orientation', () => {
expect(getChartPadding(true, LegendOrientation.Bottom, 10)).toEqual({
bottom: 10,
left: 0,
@@ -1022,7 +1022,7 @@ describe('getChartPadding', () => {
});
describe('dedupSeries', () => {
it('should deduplicate ids in series', () => {
test('should deduplicate ids in series', () => {
expect(
dedupSeries([
{
@@ -1048,17 +1048,17 @@ describe('dedupSeries', () => {
});
describe('sanitizeHtml', () => {
it('should remove html tags from series name', () => {
test('should remove html tags from series name', () => {
expect(sanitizeHtml(NULL_STRING)).toEqual('&lt;NULL&gt;');
});
});
describe('getOverMaxHiddenFormatter', () => {
it('should hide value if greater than max', () => {
test('should hide value if greater than max', () => {
const formatter = getOverMaxHiddenFormatter({ max: 81000 });
expect(formatter.format(84500)).toEqual('');
});
it('should show value if less or equal than max', () => {
test('should show value if less or equal than max', () => {
const formatter = getOverMaxHiddenFormatter({ max: 81000 });
expect(formatter.format(81000)).toEqual('81000');
expect(formatter.format(50000)).toEqual('50000');
@@ -1207,12 +1207,12 @@ test('getMinAndMaxFromBounds returns automatic lower bound when truncating', ()
});
describe('getTimeCompareStackId', () => {
it('returns the defaultId when timeCompare is empty', () => {
test('returns the defaultId when timeCompare is empty', () => {
const result = getTimeCompareStackId('default', []);
expect(result).toEqual('default');
});
it('returns the defaultId when no value in timeCompare is included in name', () => {
test('returns the defaultId when no value in timeCompare is included in name', () => {
const result = getTimeCompareStackId(
'default',
['compare1', 'compare2'],
@@ -1221,7 +1221,7 @@ describe('getTimeCompareStackId', () => {
expect(result).toEqual('default');
});
it('returns the first value in timeCompare that is included in name', () => {
test('returns the first value in timeCompare that is included in name', () => {
const result = getTimeCompareStackId(
'default',
['compare1', 'compare2'],
@@ -1230,7 +1230,7 @@ describe('getTimeCompareStackId', () => {
expect(result).toEqual('compare1');
});
it('handles name being a number', () => {
test('handles name being a number', () => {
const result = getTimeCompareStackId('default', ['123', '456'], 123);
expect(result).toEqual('123');
});

View File

@@ -58,7 +58,7 @@ const mockFormulaAnnotationLayer: FormulaAnnotationLayer = {
};
describe('transformFormulaAnnotation', () => {
it('should transform data correctly', () => {
test('should transform data correctly', () => {
expect(
transformFormulaAnnotation(
mockFormulaAnnotationLayer,
@@ -74,7 +74,7 @@ describe('transformFormulaAnnotation', () => {
]);
});
it('should swap x and y for horizontal chart', () => {
test('should swap x and y for horizontal chart', () => {
expect(
transformFormulaAnnotation(
mockFormulaAnnotationLayer,
@@ -126,7 +126,7 @@ const mockIntervalAnnotationData: AnnotationData = {
};
describe('transformIntervalAnnotation', () => {
it('should transform data correctly', () => {
test('should transform data correctly', () => {
expect(
transformIntervalAnnotation(
mockIntervalAnnotationLayer,
@@ -153,7 +153,7 @@ describe('transformIntervalAnnotation', () => {
]);
});
it('should use yAxis for horizontal chart data', () => {
test('should use yAxis for horizontal chart data', () => {
expect(
transformIntervalAnnotation(
mockIntervalAnnotationLayer,
@@ -217,7 +217,7 @@ const mockEventAnnotationData: AnnotationData = {
};
describe('transformEventAnnotation', () => {
it('should transform data correctly', () => {
test('should transform data correctly', () => {
expect(
transformEventAnnotation(
mockEventAnnotationLayer,
@@ -239,7 +239,7 @@ describe('transformEventAnnotation', () => {
]);
});
it('should use yAxis for horizontal chart data', () => {
test('should use yAxis for horizontal chart data', () => {
expect(
transformEventAnnotation(
mockEventAnnotationLayer,
@@ -292,7 +292,7 @@ const mockTimeseriesAnnotationData: AnnotationData = {
};
describe('transformTimeseriesAnnotation', () => {
it('should transform data correctly', () => {
test('should transform data correctly', () => {
expect(
transformTimeseriesAnnotation(
mockTimeseriesAnnotationLayer,
@@ -310,7 +310,7 @@ describe('transformTimeseriesAnnotation', () => {
]);
});
it('should swap x and y for horizontal chart', () => {
test('should swap x and y for horizontal chart', () => {
expect(
transformTimeseriesAnnotation(
mockTimeseriesAnnotationLayer,

View File

@@ -64,7 +64,7 @@ describe('test treeBuilder', () => {
count2: 3,
},
];
it('should build tree as expected', () => {
test('should build tree as expected', () => {
const tree = treeBuilder(data, ['foo', 'bar'], 'count');
expect(tree).toEqual([
{
@@ -168,7 +168,7 @@ describe('test treeBuilder', () => {
]);
});
it('should build tree with secondaryValue as expected', () => {
test('should build tree with secondaryValue as expected', () => {
const tree = treeBuilder(data, ['foo', 'bar'], 'count', 'count2');
expect(tree).toEqual([
{