mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
feat: apply Time Grain to X-Axis column (#21163)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { buildQueryContext } from '@superset-ui/core';
|
||||
import * as queryModule from '../../src/query/normalizeTimeColumn';
|
||||
|
||||
describe('buildQueryContext', () => {
|
||||
it('should build datasource for table sources and apply defaults', () => {
|
||||
@@ -122,4 +123,50 @@ describe('buildQueryContext', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
it('should call normalizeTimeColumn if GENERIC_CHART_AXES is enabled', () => {
|
||||
// @ts-ignore
|
||||
const spy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
|
||||
featureFlags: {
|
||||
GENERIC_CHART_AXES: true,
|
||||
},
|
||||
}));
|
||||
const spyNormalizeTimeColumn = jest.spyOn(
|
||||
queryModule,
|
||||
'normalizeTimeColumn',
|
||||
);
|
||||
|
||||
buildQueryContext(
|
||||
{
|
||||
datasource: '5__table',
|
||||
viz_type: 'table',
|
||||
},
|
||||
() => [{}],
|
||||
);
|
||||
expect(spyNormalizeTimeColumn).toBeCalled();
|
||||
spy.mockRestore();
|
||||
spyNormalizeTimeColumn.mockRestore();
|
||||
});
|
||||
it("shouldn't call normalizeTimeColumn if GENERIC_CHART_AXES is disabled", () => {
|
||||
// @ts-ignore
|
||||
const spy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
|
||||
featureFlags: {
|
||||
GENERIC_CHART_AXES: false,
|
||||
},
|
||||
}));
|
||||
const spyNormalizeTimeColumn = jest.spyOn(
|
||||
queryModule,
|
||||
'normalizeTimeColumn',
|
||||
);
|
||||
|
||||
buildQueryContext(
|
||||
{
|
||||
datasource: '5__table',
|
||||
viz_type: 'table',
|
||||
},
|
||||
() => [{}],
|
||||
);
|
||||
expect(spyNormalizeTimeColumn).not.toBeCalled();
|
||||
spy.mockRestore();
|
||||
spyNormalizeTimeColumn.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user