Skip to content

Commit

Permalink
fix: optimize test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wuding.why committed Nov 17, 2023
1 parent bdbad7e commit dcd0487
Showing 1 changed file with 19 additions and 32 deletions.
51 changes: 19 additions & 32 deletions packages/s2-core/__tests__/spreadsheet/hidden-columns-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,38 +555,25 @@ describe('SpreadSheet Hidden Columns Tests', () => {
expect(leafNodes).toHaveLength(5);
});

test('hiding the column totals should not hide the row totals', () => {
sheet.render();
const nodeId = 'root[&]总计';
const preRowNodes = sheet.facet.layoutResult.rowNodes;
const preColumnNodes = sheet.facet.layoutResult.colNodes;
sheet.interaction.hideColumns([nodeId]);

expect(sheet.facet.layoutResult.rowNodes[0].id).toBe(nodeId);
expect(sheet.facet.layoutResult.rowNodes.length).toBe(
preRowNodes.length,
);
expect(sheet.facet.layoutResult.colNodes.length).toBe(
preColumnNodes.length - 1,
);
});

test('hiding the column totals should not hide the row totals tree', () => {
sheet.setOptions({ hierarchyType: 'tree' });
sheet.render();
const nodeId = 'root[&]总计';
const preRowNodes = sheet.facet.layoutResult.rowNodes;
const preColumnNodes = sheet.facet.layoutResult.colNodes;
sheet.interaction.hideColumns([nodeId]);

expect(sheet.facet.layoutResult.rowNodes[0].id).toBe(nodeId);
expect(sheet.facet.layoutResult.rowNodes.length).toBe(
preRowNodes.length,
);
expect(sheet.facet.layoutResult.colNodes.length).toBe(
preColumnNodes.length - 1,
);
});
test.each(['grid', 'tree'])(
'hiding the column totals should not hide the row totals for %s mode',
(hierarchyType: 'grid' | 'tree') => {
sheet.setOptions({ hierarchyType });
sheet.render();
const nodeId = 'root[&]总计';
const preRowNodes = sheet.facet.layoutResult.rowNodes;
const preColumnNodes = sheet.facet.layoutResult.colNodes;
sheet.interaction.hideColumns([nodeId]);

expect(sheet.facet.layoutResult.rowNodes[0].id).toBe(nodeId);
expect(sheet.facet.layoutResult.rowNodes.length).toBe(
preRowNodes.length,
);
expect(sheet.facet.layoutResult.colNodes.length).toBe(
preColumnNodes.length - 1,
);
},
);
});
});
});

0 comments on commit dcd0487

Please sign in to comment.