-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 玉珏图重写changeData方法 && 添加单测 (#2206)
Co-authored-by: 沈建斌 <wb-sjb709429@antfin.com>
- Loading branch information
1 parent
144cf23
commit 71868f2
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,49 @@ | ||
import { RadialBar } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
import { antvStar } from '../../../data/antv-star'; | ||
|
||
describe('radial-bar changeData', () => { | ||
it('changeData: normal', () => { | ||
const bar = new RadialBar(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: antvStar, | ||
xField: 'name', | ||
yField: 'start', | ||
radius: 0.8, | ||
innerRadius: 0.2, | ||
}); | ||
bar.render(); | ||
|
||
expect(bar.chart.geometries[0].elements.length).toEqual(antvStar.length); | ||
|
||
const newData = antvStar.slice(0, 4); | ||
bar.changeData(newData); | ||
expect(bar.chart.geometries[0].elements.length).toEqual(newData.length); | ||
expect(bar.options.data).toEqual(newData); | ||
|
||
bar.destroy(); | ||
}); | ||
|
||
it('changeData: from empty to have data', () => { | ||
const bar = new RadialBar(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: [], | ||
xField: 'name', | ||
yField: 'start', | ||
radius: 0.8, | ||
innerRadius: 0.2, | ||
}); | ||
|
||
bar.render(); | ||
|
||
expect(bar.chart.geometries[0].elements.length).toEqual(0); | ||
|
||
bar.changeData(antvStar); | ||
expect(bar.chart.geometries[0].elements.length).toEqual(antvStar.length); | ||
expect(bar.options.data).toEqual(antvStar); | ||
|
||
bar.destroy(); | ||
}); | ||
}); |
This file contains 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