mirror of
https://github.com/apache/superset.git
synced 2026-04-18 07:35:09 +00:00
refactor: reorganize dateFilterUtils.tx (#14309)
* refactor: reorganize dateFilterUtils.tx * move spec to src dirctory
This commit is contained in:
@@ -26,10 +26,6 @@ import {
|
||||
shouldUseLegacyApi,
|
||||
getSimpleSQLExpression,
|
||||
} from 'src/explore/exploreUtils';
|
||||
import {
|
||||
buildTimeRangeString,
|
||||
formatTimeRange,
|
||||
} from 'src/explore/dateFilterUtils';
|
||||
import { DashboardStandaloneMode } from 'src/dashboard/util/constants';
|
||||
import * as hostNamesConfig from 'src/utils/hostNamesConfig';
|
||||
import { getChartMetadataRegistry } from '@superset-ui/core';
|
||||
@@ -264,40 +260,6 @@ describe('exploreUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildTimeRangeString', () => {
|
||||
it('generates proper time range string', () => {
|
||||
expect(
|
||||
buildTimeRangeString('2010-07-30T00:00:00', '2020-07-30T00:00:00'),
|
||||
).toBe('2010-07-30T00:00:00 : 2020-07-30T00:00:00');
|
||||
expect(buildTimeRangeString('', '2020-07-30T00:00:00')).toBe(
|
||||
' : 2020-07-30T00:00:00',
|
||||
);
|
||||
expect(buildTimeRangeString('', '')).toBe(' : ');
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatTimeRange', () => {
|
||||
it('generates a readable time range', () => {
|
||||
expect(formatTimeRange('Last 7 days')).toBe('Last 7 days');
|
||||
expect(formatTimeRange('No filter')).toBe('No filter');
|
||||
expect(formatTimeRange('Yesterday : Tomorrow')).toBe(
|
||||
'Yesterday < col < Tomorrow',
|
||||
);
|
||||
expect(
|
||||
formatTimeRange('2010-07-30T00:00:00 : 2020-07-30T00:00:00', [
|
||||
'inclusive',
|
||||
'exclusive',
|
||||
]),
|
||||
).toBe('2010-07-30 ≤ col < 2020-07-30');
|
||||
expect(
|
||||
formatTimeRange('2010-07-30T01:00:00 : ', ['exclusive', 'inclusive']),
|
||||
).toBe('2010-07-30T01:00:00 < col ≤ ∞');
|
||||
expect(formatTimeRange(' : 2020-07-30T00:00:00')).toBe(
|
||||
'-∞ < col < 2020-07-30',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSimpleSQLExpression', () => {
|
||||
it('returns empty string when subject is undefined', () => {
|
||||
expect(getSimpleSQLExpression(undefined, '=', 10)).toBe('');
|
||||
|
||||
Reference in New Issue
Block a user