-
Notifications
You must be signed in to change notification settings - Fork 200
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(layout): 修复无列头时行头对应的角头不显示 close #1929 * test: 修复测试
- Loading branch information
1 parent
1089288
commit c073578
Showing
14 changed files
with
508 additions
and
46 deletions.
There are no files selected for viewing
190 changes: 190 additions & 0 deletions
190
packages/s2-core/__tests__/spreadsheet/__snapshots__/corner-spec.ts.snap
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,190 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PivotSheet Corner Tests should render row corner when columns and values is empty 1`] = ` | ||
Array [ | ||
Object { | ||
"belongsCell": undefined, | ||
"children": Array [], | ||
"colIndex": -1, | ||
"cornerType": "row", | ||
"extra": undefined, | ||
"field": "province", | ||
"height": 30, | ||
"id": "", | ||
"inCollapseNode": undefined, | ||
"isCollapsed": undefined, | ||
"isGrandTotals": undefined, | ||
"isLeaf": undefined, | ||
"isPivotMode": true, | ||
"isSubTotals": undefined, | ||
"isTotalMeasure": undefined, | ||
"isTotals": undefined, | ||
"key": "province", | ||
"label": "province", | ||
"level": undefined, | ||
"padding": 0, | ||
"query": undefined, | ||
"rowIndex": undefined, | ||
"seriesNumberWidth": undefined, | ||
"value": "province", | ||
"width": 100, | ||
"x": 0, | ||
"y": 0, | ||
}, | ||
Object { | ||
"belongsCell": undefined, | ||
"children": Array [], | ||
"colIndex": -1, | ||
"cornerType": "row", | ||
"extra": undefined, | ||
"field": "city", | ||
"height": 30, | ||
"id": "", | ||
"inCollapseNode": undefined, | ||
"isCollapsed": undefined, | ||
"isGrandTotals": undefined, | ||
"isLeaf": undefined, | ||
"isPivotMode": true, | ||
"isSubTotals": undefined, | ||
"isTotalMeasure": undefined, | ||
"isTotals": undefined, | ||
"key": "city", | ||
"label": "city", | ||
"level": undefined, | ||
"padding": 0, | ||
"query": undefined, | ||
"rowIndex": undefined, | ||
"seriesNumberWidth": undefined, | ||
"value": "city", | ||
"width": 100, | ||
"x": 100, | ||
"y": 0, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`PivotSheet Corner Tests should render row corner when columns is empty and measure hidden 1`] = ` | ||
Array [ | ||
Object { | ||
"belongsCell": undefined, | ||
"children": Array [], | ||
"colIndex": -1, | ||
"cornerType": "row", | ||
"extra": undefined, | ||
"field": "province", | ||
"height": 30, | ||
"id": "", | ||
"inCollapseNode": undefined, | ||
"isCollapsed": undefined, | ||
"isGrandTotals": undefined, | ||
"isLeaf": undefined, | ||
"isPivotMode": true, | ||
"isSubTotals": undefined, | ||
"isTotalMeasure": undefined, | ||
"isTotals": undefined, | ||
"key": "province", | ||
"label": "province", | ||
"level": undefined, | ||
"padding": 0, | ||
"query": undefined, | ||
"rowIndex": undefined, | ||
"seriesNumberWidth": undefined, | ||
"value": "province", | ||
"width": 150, | ||
"x": 0, | ||
"y": 0, | ||
}, | ||
Object { | ||
"belongsCell": undefined, | ||
"children": Array [], | ||
"colIndex": -1, | ||
"cornerType": "row", | ||
"extra": undefined, | ||
"field": "city", | ||
"height": 30, | ||
"id": "", | ||
"inCollapseNode": undefined, | ||
"isCollapsed": undefined, | ||
"isGrandTotals": undefined, | ||
"isLeaf": undefined, | ||
"isPivotMode": true, | ||
"isSubTotals": undefined, | ||
"isTotalMeasure": undefined, | ||
"isTotals": undefined, | ||
"key": "city", | ||
"label": "city", | ||
"level": undefined, | ||
"padding": 0, | ||
"query": undefined, | ||
"rowIndex": undefined, | ||
"seriesNumberWidth": undefined, | ||
"value": "city", | ||
"width": 150, | ||
"x": 150, | ||
"y": 0, | ||
}, | ||
] | ||
`; | ||
|
||
exports[`PivotSheet Corner Tests should render row corner when measure hidden 1`] = ` | ||
Array [ | ||
Object { | ||
"belongsCell": undefined, | ||
"children": Array [], | ||
"colIndex": -1, | ||
"cornerType": "row", | ||
"extra": undefined, | ||
"field": "province", | ||
"height": 30, | ||
"id": "", | ||
"inCollapseNode": undefined, | ||
"isCollapsed": undefined, | ||
"isGrandTotals": undefined, | ||
"isLeaf": undefined, | ||
"isPivotMode": true, | ||
"isSubTotals": undefined, | ||
"isTotalMeasure": undefined, | ||
"isTotals": undefined, | ||
"key": "province", | ||
"label": "province", | ||
"level": undefined, | ||
"padding": 0, | ||
"query": undefined, | ||
"rowIndex": undefined, | ||
"seriesNumberWidth": undefined, | ||
"value": "province", | ||
"width": 100, | ||
"x": 0, | ||
"y": 0, | ||
}, | ||
Object { | ||
"belongsCell": undefined, | ||
"children": Array [], | ||
"colIndex": -1, | ||
"cornerType": "row", | ||
"extra": undefined, | ||
"field": "city", | ||
"height": 30, | ||
"id": "", | ||
"inCollapseNode": undefined, | ||
"isCollapsed": undefined, | ||
"isGrandTotals": undefined, | ||
"isLeaf": undefined, | ||
"isPivotMode": true, | ||
"isSubTotals": undefined, | ||
"isTotalMeasure": undefined, | ||
"isTotals": undefined, | ||
"key": "city", | ||
"label": "city", | ||
"level": undefined, | ||
"padding": 0, | ||
"query": undefined, | ||
"rowIndex": undefined, | ||
"seriesNumberWidth": undefined, | ||
"value": "city", | ||
"width": 100, | ||
"x": 100, | ||
"y": 0, | ||
}, | ||
] | ||
`; |
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,114 @@ | ||
import * as simpleDataConfig from 'tests/data/simple-data.json'; | ||
import { DEFAULT_STYLE, type SpreadSheet } from '../../src'; | ||
import { createPivotSheet } from '../util/helpers'; | ||
|
||
describe('PivotSheet Corner Tests', () => { | ||
let s2: SpreadSheet; | ||
|
||
beforeEach(() => { | ||
s2 = createPivotSheet({ | ||
width: 300, | ||
height: 300, | ||
}); | ||
s2.render(); | ||
}); | ||
|
||
afterEach(() => { | ||
s2.destroy(); | ||
}); | ||
|
||
// https://github.com/antvis/S2/issues/1929 | ||
test('should render row corner when columns is empty and measure hidden', () => { | ||
s2.setDataCfg({ | ||
...simpleDataConfig, | ||
fields: { | ||
...simpleDataConfig.fields, | ||
columns: [], | ||
}, | ||
}); | ||
s2.setOptions({ | ||
style: { | ||
colCfg: { | ||
hideMeasureColumn: true, | ||
}, | ||
}, | ||
}); | ||
s2.render(); | ||
|
||
const cornerNodes = s2.facet.getCornerNodes(); | ||
const { colsHierarchy } = s2.facet.layoutResult; | ||
|
||
expect(colsHierarchy.width).toEqual(0); | ||
expect(colsHierarchy.height).toEqual(DEFAULT_STYLE.colCfg.height); | ||
expect(colsHierarchy.sampleNodeForLastLevel.y).toEqual(0); | ||
expect(colsHierarchy.sampleNodeForLastLevel.height).toEqual( | ||
DEFAULT_STYLE.colCfg.height, | ||
); | ||
expect(cornerNodes).toHaveLength(2); | ||
expect(s2.facet.getCornerNodes()).toMatchSnapshot(); | ||
}); | ||
|
||
test('should render row corner when measure hidden', () => { | ||
s2.setOptions({ | ||
style: { | ||
colCfg: { | ||
hideMeasureColumn: true, | ||
}, | ||
}, | ||
}); | ||
s2.render(); | ||
|
||
const cornerNodes = s2.facet.getCornerNodes(); | ||
const { colsHierarchy } = s2.facet.layoutResult; | ||
|
||
expect(colsHierarchy.width).toEqual(100); | ||
expect(colsHierarchy.height).toEqual(DEFAULT_STYLE.colCfg.height); | ||
expect(colsHierarchy.sampleNodeForLastLevel.y).toEqual(0); | ||
expect(colsHierarchy.sampleNodeForLastLevel.height).toEqual( | ||
DEFAULT_STYLE.colCfg.height, | ||
); | ||
expect(cornerNodes).toHaveLength(2); | ||
expect(s2.facet.getCornerNodes()).toMatchSnapshot(); | ||
}); | ||
|
||
test('should render row corner when columns and values is empty', () => { | ||
s2.setDataCfg({ | ||
...simpleDataConfig, | ||
fields: { | ||
...simpleDataConfig.fields, | ||
columns: [], | ||
values: [], | ||
}, | ||
}); | ||
s2.render(); | ||
|
||
const cornerNodes = s2.facet.getCornerNodes(); | ||
const { colsHierarchy } = s2.facet.layoutResult; | ||
|
||
expect(colsHierarchy.width).toEqual(0); | ||
expect(colsHierarchy.height).toEqual(0); | ||
expect(colsHierarchy.sampleNodeForLastLevel).toBeNull(); | ||
expect(cornerNodes).toHaveLength(2); | ||
expect(cornerNodes).toMatchSnapshot(); | ||
}); | ||
|
||
test('should not render row corner when fields is empty', () => { | ||
s2.setDataCfg({ | ||
...simpleDataConfig, | ||
fields: { | ||
rows: [], | ||
columns: [], | ||
values: [], | ||
}, | ||
}); | ||
s2.render(); | ||
|
||
const cornerNodes = s2.facet.getCornerNodes(); | ||
const { colsHierarchy } = s2.facet.layoutResult; | ||
|
||
expect(colsHierarchy.width).toEqual(0); | ||
expect(colsHierarchy.height).toEqual(0); | ||
expect(colsHierarchy.sampleNodeForLastLevel).toBeNull(); | ||
expect(cornerNodes).toHaveLength(0); | ||
}); | ||
}); |
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
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
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
Oops, something went wrong.
c073578
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
antvis-s2 – ./
antvis-s2.vercel.app
antvis-s2-git-master-antv-s2.vercel.app
antvis-s2-antv-s2.vercel.app