Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ChartType } from '../../src';
import { getChartSpecWithContext } from '../../src/atom/chartGenerator/spec';

describe('getChartSpecWithContext', () => {
it('should generate correct basic liquid spec', () => {
const data = [{ value: 0.76 }];
const context = {
chartTypeList: Object.values(ChartType),
dataTable: data,
command: 'Genarate a basic liquid chart',
cell: {
value: 'value'
},
chartType: ChartType.LiquidChart.toUpperCase()
};
const { chartType, spec } = getChartSpecWithContext(context);
expect(chartType).toBe(ChartType.LiquidChart);
expect(spec.type).toBe('liquid');
expect(spec.valueField).not.toBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接toBe cell.value更准确一些

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indicatorSmartInvert这个配置也可以加一下对比

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

expect(spec.data.values).toEqual(data);
});

it('should generate correct basic liquid spec with custom title', () => {
const data = [{ title: '当前进度', value: 0.76 }];
const context = {
chartTypeList: Object.values(ChartType),
dataTable: data,
command: 'Genarate a basic liquid chart',
cell: {
x: 'title',
value: 'value'
},
chartType: ChartType.LiquidChart.toUpperCase()
};
const { chartType, spec } = getChartSpecWithContext(context);
expect(chartType).toBe(ChartType.LiquidChart);
expect(spec.type).toBe('liquid');
expect(spec.data.values).toEqual(data);
expect(spec.valueField).not.toBeNull();
expect(spec.indicator.title.style.text).toBe('当前进度');
});
});