-
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方法 && 添加单测 (#2212)
Co-authored-by: 沈建斌 <wb-sjb709429@antfin.com>
- Loading branch information
1 parent
a842cf6
commit 547d7dd
Showing
2 changed files
with
57 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,46 @@ | ||
import { Waterfall } from '../../../../src'; | ||
import { salesByArea } from '../../../data/sales'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
describe('waterfall changeData', () => { | ||
it('changeData: normal', () => { | ||
const waterfall = new Waterfall(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: salesByArea, | ||
xField: 'area', | ||
yField: 'sales', | ||
}); | ||
|
||
waterfall.render(); | ||
|
||
expect(waterfall.chart.geometries[0].elements.length).toEqual(salesByArea.length + 1); | ||
|
||
const newData = salesByArea.slice(0, 4); | ||
waterfall.changeData(newData); | ||
expect(waterfall.chart.geometries[0].elements.length).toEqual(newData.length + 1); | ||
expect(waterfall.options.data).toEqual(newData); | ||
|
||
waterfall.destroy(); | ||
}); | ||
|
||
it('changeData: from empty to have data', () => { | ||
const waterfall = new Waterfall(createDiv(), { | ||
width: 400, | ||
height: 300, | ||
data: [], | ||
xField: 'area', | ||
yField: 'sales', | ||
}); | ||
|
||
waterfall.render(); | ||
|
||
expect(waterfall.chart.geometries[0].elements.length).toEqual(0); | ||
|
||
waterfall.changeData(salesByArea); | ||
expect(waterfall.chart.geometries[0].elements.length).toEqual(salesByArea.length + 1); | ||
expect(waterfall.options.data).toEqual(salesByArea); | ||
|
||
waterfall.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