-
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
3 changed files
with
81 additions
and
11 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
packages/s2-core/__tests__/spreadsheet/empty-dataset-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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { getContainer } from 'tests/util/helpers'; | ||
import { PivotSheet, TableSheet } from '@/sheet-type'; | ||
import type { S2Options } from '@/common/interface/s2Options'; | ||
|
||
const s2Options: S2Options = { | ||
width: 400, | ||
height: 400, | ||
hierarchyType: 'grid', | ||
}; | ||
|
||
describe('Empty Dataset Structure Tests', () => { | ||
test('should generate placeholder for pivot mode with single dimension', () => { | ||
const container = getContainer(); | ||
|
||
const s2DataCfg = { | ||
fields: { | ||
rows: ['province', 'city'], | ||
columns: ['type'], | ||
values: ['price'], | ||
valueInCols: true, | ||
}, | ||
data: [], | ||
}; | ||
const s2 = new PivotSheet(container, s2DataCfg, s2Options); | ||
s2.render(); | ||
|
||
// @ts-ignore | ||
expect(s2.facet.panelScrollGroupIndexes).toEqual([0, 0, 0, 0]); | ||
}); | ||
|
||
test('should generate placeholder for pivot mode with two dimensions', () => { | ||
const container = getContainer(); | ||
|
||
const s2DataCfg = { | ||
fields: { | ||
rows: ['province', 'city'], | ||
columns: ['type'], | ||
values: ['price', 'cost'], | ||
valueInCols: true, | ||
}, | ||
data: [], | ||
}; | ||
const s2 = new PivotSheet(container, s2DataCfg, s2Options); | ||
s2.render(); | ||
// @ts-ignore | ||
expect(s2.facet.panelScrollGroupIndexes).toEqual([0, 1, 0, 0]); | ||
}); | ||
|
||
test(`shouldn't generate placeholder for table mode`, () => { | ||
const container = getContainer(); | ||
|
||
const s2DataCfg = { | ||
fields: { | ||
columns: ['province', 'city', 'type', 'price', 'cost'], | ||
}, | ||
data: [], | ||
}; | ||
const s2 = new TableSheet(container, s2DataCfg, s2Options); | ||
s2.render(); | ||
// @ts-ignore | ||
expect(s2.facet.panelScrollGroupIndexes).toEqual([]); | ||
}); | ||
}); |
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