-
Notifications
You must be signed in to change notification settings - Fork 86
test: add test getChartSpecWithContext with lineChart #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RubMaker
wants to merge
1
commit into
VisActor:develop
Choose a base branch
from
RubMaker:test/add-test-chartType-linechart
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
packages/vmind/__tests__/unit/getChartSpecWithContext.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { getChartSpecWithContext } from '../../src/atom/chartGenerator/spec'; | ||
import type { GenerateChartCellContext } from '../../src/atom/chartGenerator/type'; | ||
import { ChartType } from '../../src/types'; | ||
import { DataType } from '../../src/types/base'; | ||
import { ROLE } from '../../src/types/base'; | ||
|
||
it('Linechart', () => { | ||
const context = { | ||
chartTypeList: [ | ||
'Bar Chart', | ||
'Line Chart', | ||
'Area Chart', | ||
'Pie Chart', | ||
'Scatter Plot', | ||
'Word Cloud', | ||
'Rose Chart', | ||
'Radar Chart', | ||
'Sankey Chart', | ||
'Funnel Chart', | ||
'Dual Axis Chart', | ||
'Waterfall Chart', | ||
'Box Plot', | ||
'Linear Progress chart', | ||
'Circular Progress chart', | ||
'Liquid Chart', | ||
'Bubble Circle Packing', | ||
'Map Chart', | ||
'Range Column Chart', | ||
'Sunburst Chart', | ||
'Treemap Chart', | ||
'Gauge Chart', | ||
'Basic Heat Map', | ||
'Venn Chart', | ||
'Dynamic Bar Chart' | ||
], | ||
dataTable: [ | ||
{ time: '2:00', value: 38 }, | ||
{ time: '4:00', value: 56 }, | ||
{ time: '6:00', value: 10 }, | ||
{ time: '8:00', value: 70 }, | ||
{ time: '10:00', value: 36 }, | ||
{ time: '12:00', value: 94 }, | ||
{ time: '14:00', value: 24 }, | ||
{ time: '16:00', value: 44 }, | ||
{ time: '18:00', value: 36 }, | ||
{ time: '20:00', value: 68 }, | ||
{ time: '22:00', value: 22 } | ||
], | ||
command: 'Generate a line chart with time on the x-axis and value on the y-axis', | ||
cell: { | ||
x: 'time', | ||
y: 'value', | ||
category: 'time' | ||
}, | ||
transpose: false, | ||
chartType: ChartType.LineChart.toUpperCase(), | ||
fieldInfo: [ | ||
{ | ||
fieldName: 'time', | ||
type: 'string', | ||
role: 'dimension' | ||
}, | ||
{ | ||
fieldName: 'value', | ||
type: 'number', | ||
role: 'dimension' | ||
} | ||
] | ||
}; | ||
const { chartType, spec } = getChartSpecWithContext(context); | ||
expect(chartType).toBe(ChartType.LineChart); | ||
expect(spec.type).toBe('line'); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个测试太简单了,起不到本质上的意义,不能覆盖各种大模型产出线图的场景