Skip to content

Commit 690e2fe

Browse files
committed
Tests now account for granularity being proccesed. Replaced previous test:result pair with test:desired_result and desired_test:result.
1 parent 29d0227 commit 690e2fe

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

superset-frontend/plugins/plugin-chart-echarts/test/BigNumber/transformProps.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,29 @@ describe('BigNumberWithTrendline', () => {
133133
// bigNumberFallback is only set when bigNumber is null after aggregation
134134
expect(transformed.bigNumberFallback).toBeNull();
135135

136-
// should successfully formatTime by granularity
136+
// should successfully formatTime by granularity(QUARTER)
137+
// @ts-ignore
138+
expect(transformed.formatTime(new Date('2020-01-01'))).toStrictEqual(
139+
'2020 Q1',
140+
);
141+
});
142+
143+
it('should format time with by "SECOND" granularity only if time_grain_sqla were TimeGranularity.SECOND', () => {
144+
const propsWithSecondGranularity = {
145+
...props,
146+
// ensure extractTimegrain() gets SECOND granularity
147+
rawFormData: {
148+
...rawFormData,
149+
time_grain_sqla: TimeGranularity.SECOND,
150+
},
151+
formData: {
152+
...props.formData,
153+
timeGrainSqla: TimeGranularity.SECOND,
154+
},
155+
} as unknown as BigNumberWithTrendlineChartProps;
156+
157+
const transformed = transformProps(propsWithSecondGranularity);
158+
// should successfully formatTime by granularity(SECOND)
137159
// @ts-ignore
138160
expect(transformed.formatTime(new Date('2020-01-01'))).toStrictEqual(
139161
'2020-01-01 00:00:00',

0 commit comments

Comments
 (0)