Skip to content

Commit

Permalink
chore: tweak unittest (apache#1460)
Browse files Browse the repository at this point in the history
* chore: tweak unittest

lint

* lint
  • Loading branch information
zhaoyongjie committed Nov 25, 2021
1 parent 3168a23 commit c4e7ee6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { JsonObject } from '@superset-ui/core';
import {
AnnotationLayer,
AnnotationOpacity,
Expand All @@ -25,7 +26,6 @@ import {
buildQueryObject,
QueryObject,
} from '../../src/query';
import { JsonObject } from '../../lib';

describe('buildQueryObject', () => {
let query: QueryObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import extractTimegrain from '@superset-ui/core/src/query/extractTimegrain';
import { QueryFormData } from '../../lib';
import { QueryFormData } from '@superset-ui/core';

describe('extractTimegrain', () => {
const baseFormData: QueryFormData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ describe('AnnotationLayer type guards', () => {
value: 'sin(2*x)',
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const eventAnnotationLayer: EventAnnotationLayer = {
annotationType: AnnotationType.Event,
name: 'My Event',
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
sourceType: AnnotationSourceType.Native,
};
const intervalAnnotationLayer: IntervalAnnotationLayer = {
Expand All @@ -60,6 +62,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const timeseriesAnnotationLayer: TimeseriesAnnotationLayer = {
annotationType: AnnotationType.Timeseries,
Expand All @@ -68,6 +71,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const tableAnnotationLayer: TableAnnotationLayer = {
annotationType: AnnotationType.Interval,
Expand All @@ -76,6 +80,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const timeseriesAnnotationResult: TimeseriesAnnotationResult = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ describe('smartDateDetailedFormatter', () => {
});

it('shows only year when 1st day of the year', () => {
expect(formatter(new Date('2020-01-01 0:00:00'))).toBe('2020');
expect(formatter(new Date('2020-01-01T00:00:00.000+00:00'))).toBe('2020');
});

it('shows full date when a regular date', () => {
expect(formatter(new Date('2020-03-01 00:00:00'))).toBe('2020-03-01');
expect(formatter(new Date('2020-03-01T00:00:00.000+00:00'))).toBe('2020-03-01');
});

it('shows full date including time of day without seconds when hour precision', () => {
expect(formatter(new Date('2020-03-01 13:00:00'))).toBe('2020-03-01 13:00');
expect(formatter(new Date('2020-03-01T13:00:00.000+00:00'))).toBe('2020-03-01 13:00');
});

it('shows full date including time of day when minute precision', () => {
expect(formatter(new Date('2020-03-10 13:10:00'))).toBe('2020-03-10 13:10');
expect(formatter(new Date('2020-03-10T13:10:00.000+00:00'))).toBe('2020-03-10 13:10');
});

it('shows full date including time of day when subsecond precision', () => {
expect(formatter(new Date('2020-03-10 13:10:00.1'))).toBe('2020-03-10 13:10:00.100');
expect(formatter(new Date('2020-03-10T13:10:00.100+00:00'))).toBe('2020-03-10 13:10:00.100');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export { default as EchartsFunnelChartPlugin } from './Funnel';
export { default as EchartsTreeChartPlugin } from './Tree';
export { default as EchartsTreemapChartPlugin } from './Treemap';

export * from './types';

/**
* Note: this file exports the default export from EchartsTimeseries.tsx.
* If you want to export multiple visualization modules, you will need to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@ export const DEFAULT_TITLE_FORM_DATA: EchartsTitleFormData = {
yAxisTitleMargin: 0,
yAxisTitlePosition: 'Top',
};

export * from './Timeseries/types';
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from '../../src/utils/series';
import { LegendOrientation, LegendType } from '../../src/types';
import { defaultLegendPadding } from '../../src/defaults';
import { NULL_STRING } from '../../lib/constants';
import { NULL_STRING } from '../../src/constants';

describe('extractTimeseriesSeries', () => {
it('should generate a valid ECharts timeseries series object', () => {
Expand Down

0 comments on commit c4e7ee6

Please sign in to comment.