-
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.
- Loading branch information
Showing
34 changed files
with
832 additions
and
741 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
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
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
103 changes: 36 additions & 67 deletions
103
packages/s2-core/__tests__/unit/facet/header/frozen-row-spec.ts
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 |
---|---|---|
@@ -1,104 +1,73 @@ | ||
import { createPivotSheet } from 'tests/util/helpers'; | ||
import { assembleDataCfg, assembleOptions } from 'tests/util'; | ||
import { DEFAULT_STYLE } from '@/common'; | ||
|
||
import { FrozenRowCell, RowCell, SeriesNumberCell } from '@/cell'; | ||
import type { PivotFacet } from '@/facet'; | ||
import { FrozenRowHeader } from '@/facet/header'; | ||
import { FrozenSeriesNumber } from '@/facet/header/frozen-series-number'; | ||
|
||
const s2 = createPivotSheet({ | ||
...assembleDataCfg().fields, | ||
valueInCols: true, | ||
...assembleOptions({ | ||
frozenEntireHeadRowPivot: true, | ||
totals: { | ||
row: { | ||
showGrandTotals: true, | ||
reverseLayout: true, | ||
}, | ||
}, | ||
frozenColCount: 2, | ||
frozenRowCount: 2, | ||
frozenTrailingColCount: 2, | ||
frozenTrailingRowCount: 2, | ||
import { get } from 'lodash'; | ||
import { DEFAULT_OPTIONS } from '@/common'; | ||
import { FrozenRowCell, SeriesNumberCell } from '@/cell'; | ||
import { PivotRowHeader } from '@/facet/header'; | ||
import { SeriesNumberHeader } from '@/facet/header/series-number'; | ||
|
||
const s2 = createPivotSheet( | ||
{ | ||
...DEFAULT_OPTIONS, | ||
frozenFirstRowPivot: true, | ||
totals: { row: { showGrandTotals: true, reverseLayout: true } }, | ||
showSeriesNumber: true, | ||
}), | ||
...DEFAULT_STYLE, | ||
height: 480, | ||
width: 400, | ||
cellCfg: { | ||
width: 200, | ||
height: 50, | ||
}, | ||
}); | ||
describe('Frozen Row Header Test', () => { | ||
let facet; | ||
{ useSimpleData: false }, | ||
); | ||
|
||
describe('Frozen Row Header Test', () => { | ||
test.each(['grid', 'tree'])( | ||
'frozen row header group api', | ||
(hierarchyType: 'grid' | 'tree') => { | ||
s2.setOptions({ hierarchyType }); | ||
s2.render(); | ||
facet = s2.facet as PivotFacet; | ||
const rowHeader: PivotRowHeader = s2.facet.rowHeader as PivotRowHeader; | ||
|
||
expect(facet.rowHeader instanceof FrozenRowHeader).toBeTrue(); | ||
expect(facet.rowHeader.frozenHeadGroup).toBeTruthy(); | ||
expect(facet.rowHeader.scrollGroup).toBeTruthy(); | ||
expect(rowHeader instanceof PivotRowHeader).toBeTrue(); | ||
expect(rowHeader.frozenHeadGroup).toBeTruthy(); | ||
expect(rowHeader.scrollGroup).toBeTruthy(); | ||
|
||
expect(facet.rowHeader.frozenHeadGroup.getChildren()).toHaveLength(1); | ||
const frozenRowCell = facet.rowHeader.frozenHeadGroup.getChildren()[0]; | ||
expect(rowHeader.frozenHeadGroup.getChildren()).toHaveLength(1); | ||
const frozenRowCell = rowHeader.frozenHeadGroup.getChildren()[0]; | ||
|
||
expect(frozenRowCell instanceof RowCell).toBeTrue(); | ||
expect(frozenRowCell.meta.height).toEqual(30); | ||
expect(frozenRowCell instanceof FrozenRowCell).toBeTrue(); | ||
expect(get(frozenRowCell, 'meta.height')).toEqual(30); | ||
|
||
expect(facet.rowHeader.scrollGroup.getChildren()).toHaveLength(3); | ||
const scrollCell = facet.rowHeader.scrollGroup.getChildren()[0]; | ||
expect(rowHeader.scrollGroup.getChildren()).toHaveLength(10); | ||
const scrollCell = rowHeader.scrollGroup.getChildren()[0]; | ||
|
||
expect(scrollCell instanceof FrozenRowCell).toBeTrue(); | ||
expect(frozenRowCell.meta.height).toEqual(30); | ||
|
||
const rowHeader = facet.rowHeader; | ||
expect(rowHeader.getFrozenRowHeight()).toBe(30); | ||
|
||
expect( | ||
rowHeader.isFrozenRow({ | ||
rowIndex: 0, | ||
}), | ||
).toBe(true); | ||
expect( | ||
rowHeader.isFrozenRow({ | ||
rowIndex: -1, | ||
}), | ||
).toBe(false); | ||
expect(get(frozenRowCell, 'meta.height')).toEqual(30); | ||
|
||
expect(rowHeader.getFrozenRowCount()).toBe(1); | ||
expect(rowHeader.getFrozenFirstRowHeight()).toBe(30); | ||
}, | ||
); | ||
}); | ||
|
||
describe('Frozen Series Number Test', () => { | ||
let facet; | ||
test.each(['grid', 'tree'])( | ||
'series number test', | ||
(hierarchyType: 'grid' | 'tree') => { | ||
s2.setOptions({ hierarchyType }); | ||
s2.render(); | ||
facet = s2.facet as PivotFacet; | ||
expect(facet.rowIndexHeader instanceof FrozenSeriesNumber).toBe(true); | ||
const rowIndexHeader: SeriesNumberHeader = s2.facet | ||
.rowIndexHeader as SeriesNumberHeader; | ||
expect(rowIndexHeader instanceof SeriesNumberHeader).toBe(true); | ||
|
||
const seriesNumberCell = | ||
facet.rowIndexHeader.frozenHeadGroup.getChildren(); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
const seriesNumberCell = rowIndexHeader.frozenHeadGroup.getChildren(); | ||
expect(seriesNumberCell).toHaveLength(1); | ||
|
||
expect( | ||
facet.rowIndexHeader.scrollGroup.getChildren()[0] instanceof | ||
SeriesNumberCell, | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
rowIndexHeader.scrollGroup.getChildren()[0] instanceof SeriesNumberCell, | ||
).toBe(true); | ||
|
||
expect(seriesNumberCell[0] instanceof SeriesNumberCell).toBe(true); | ||
|
||
expect(seriesNumberCell[0].meta.height).toBe(30); | ||
expect(get(seriesNumberCell[0], 'meta.height')).toBe(30); | ||
}, | ||
); | ||
}); |
Oops, something went wrong.