-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix: 修复树状模式下一组数据只有一条数据时, 叶子节点判断错误, 也渲染了展开/收起图标 close #2804
- Loading branch information
1 parent
2c28e84
commit fa5bb9b
Showing
3 changed files
with
67 additions
and
6 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,33 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
/** | ||
* 透视表树状模式当某一组数据只有一条数据时, 叶子节点判断错误, 也渲染了展开/收起图标. | ||
* @description spec for issue #2804 | ||
* https://github.com/antvis/S2/issues/2804 | ||
*/ | ||
import { S2Options } from '../../src'; | ||
import * as mockDataConfig from '../data/data-issue-2804.json'; | ||
import { getContainer } from '../util/helpers'; | ||
import { PivotSheet } from '@/sheet-type'; | ||
|
||
const s2Options: S2Options = { | ||
width: 800, | ||
height: 600, | ||
hierarchyType: 'tree', | ||
}; | ||
|
||
describe('Tree Leaf Node Status Tests', () => { | ||
test('should get correctly tree icon and leaf node status', () => { | ||
const s2 = new PivotSheet(getContainer(), mockDataConfig, s2Options); | ||
|
||
s2.render(); | ||
|
||
const [a1, a2] = s2.getRowNodes(); | ||
|
||
expect(a1.isLeaf).toBeTruthy(); | ||
expect(a1.isTotals).toBeFalsy(); | ||
expect(a2.isLeaf).toBeFalsy(); | ||
expect(a2.isTotals).toBeTruthy(); | ||
expect(a1.belongsCell.treeIcon).not.toBeDefined(); | ||
expect(a2.belongsCell.treeIcon).toBeDefined(); | ||
}); | ||
}); |
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,21 @@ | ||
{ | ||
"fields": { | ||
"rows": ["row0", "row1"], | ||
"columns": ["col0"], | ||
"values": ["cost"], | ||
"valueInCols": true | ||
}, | ||
"data": [ | ||
{ | ||
"row0": "a-1", | ||
"col0": "b-1", | ||
"cost": 2 | ||
}, | ||
{ | ||
"row0": "a-2", | ||
"row1": "a-2-1", | ||
"col0": "b-2", | ||
"cost": 3 | ||
} | ||
] | ||
} |
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