chore: tweak unittest (#1460)

* chore: tweak unittest

lint

* lint
This commit is contained in:
Yongjie Zhao
2021-11-09 10:34:07 +00:00
parent 67f1083af6
commit 1896c842d6
7 changed files with 17 additions and 8 deletions

View File

@@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { JsonObject } from '@superset-ui/core';
import {
AnnotationLayer,
AnnotationOpacity,
@@ -25,7 +26,6 @@ import {
buildQueryObject,
QueryObject,
} from '../../src/query';
import { JsonObject } from '../../lib';
describe('buildQueryObject', () => {
let query: QueryObject;

View File

@@ -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 = {

View File

@@ -44,6 +44,7 @@ describe('AnnotationLayer type guards', () => {
value: 'sin(2*x)',
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const eventAnnotationLayer: EventAnnotationLayer = {
annotationType: AnnotationType.Event,
@@ -51,6 +52,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
sourceType: AnnotationSourceType.Native,
};
const intervalAnnotationLayer: IntervalAnnotationLayer = {
@@ -60,6 +62,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const timeseriesAnnotationLayer: TimeseriesAnnotationLayer = {
annotationType: AnnotationType.Timeseries,
@@ -68,6 +71,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const tableAnnotationLayer: TableAnnotationLayer = {
annotationType: AnnotationType.Interval,
@@ -76,6 +80,7 @@ describe('AnnotationLayer type guards', () => {
value: 1,
style: AnnotationStyle.Solid,
show: true,
showLabel: false,
};
const timeseriesAnnotationResult: TimeseriesAnnotationResult = [
{

View File

@@ -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');
});
});

View File

@@ -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

View File

@@ -132,3 +132,5 @@ export const DEFAULT_TITLE_FORM_DATA: EchartsTitleFormData = {
yAxisTitleMargin: 0,
yAxisTitlePosition: 'Top',
};
export * from './Timeseries/types';

View File

@@ -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', () => {