Skip to content

Commit

Permalink
test(layout): 完善紧凑模式下列头带有排序icon场景的列宽计算单测
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxxZ-zhang committed Apr 18, 2024
1 parent c34729b commit ece6e2a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/s2-core/__tests__/bugs/issue-2385-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const s2Options: S2Options = {
},
layoutWidthType: 'compact',
},
showDefaultHeaderActionIcon: true,
};

describe('Compare Layout Tests', () => {
Expand All @@ -31,6 +32,15 @@ describe('Compare Layout Tests', () => {
s2.render();

const colLeafNodes = s2.facet.layoutResult.colLeafNodes;

const measureCell = s2.panelGroup.cfg.children[0].cfg.children[8];
const cellStyle = measureCell.getStyle() || measureCell.theme.dataCell;
const {
padding: { left = 0, right = 0 },
} = cellStyle?.cell;
expect(measureCell.getMaxTextWidth()).toEqual(
colLeafNodes[2].width - left - right,
);
expect(Math.floor(colLeafNodes[0].width)).toBeCloseTo(179);
expect(Math.floor(colLeafNodes[1].width)).toEqual(98);
});
Expand Down
28 changes: 28 additions & 0 deletions packages/s2-core/__tests__/data/data-issue-2385.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,34 @@
"province": "吉林",
"price": "3",
"cost": "1.5"
},
{
"type": "圆规",
"province": "浙江",
"city": "杭州",
"price": "111",
"cost": "1.5"
},
{
"type": "圆规",
"province": "浙江",
"city": "舟山",
"price": "111",
"cost": "1.5"
},
{
"type": "圆规",
"province": "吉林",
"city": "长春",
"price": "11122",
"cost": "1.5"
},
{
"type": "圆规",
"province": "吉林",
"city": "白山",
"price": "111",
"cost": "1.5"
}
],
"fields": {
Expand Down

0 comments on commit ece6e2a

Please sign in to comment.