= {
fields: {
...StrategySheetDataConfig.fields,
valueInCols: false,
},
};
- const s2Options = {
+
+ const s2Options: SheetComponentOptions = {
cornerExtraFieldText,
};
@@ -206,16 +207,17 @@ describe(' Tests', () => {
...s2DataCfg,
});
- const cornerNode = s2.facet
- .getCornerNodes()
- .find((node) => node.cornerType === CornerNodeType.Row);
+ await waitFor(() => {
+ const cornerNode = s2.facet
+ .getCornerNodes()
+ .find((node) => node.cornerType === CornerNodeType.Row);
- const textList = s2.facet
- .getCornerCells()
- .map((cell) => cell.getActualText());
+ const textList = s2.facet.getCornerNodes().map((node) => node.value);
+ const cornerText = `自定义节点A/指标E/${cornerExtraFieldText}`;
- expect(textList).toEqual([cornerExtraFieldText, '日期']);
- expect(cornerNode!.value).toEqual(cornerExtraFieldText);
+ expect(textList).toEqual([cornerText, '日期']);
+ expect(cornerNode!.value).toEqual(cornerText);
+ });
});
test('should format corner date field', async () => {
@@ -240,7 +242,7 @@ describe(' Tests', () => {
.getCornerCells()
.map((cell) => cell.getActualText());
- expect(cornerTextList).toEqual(['自定义节点A/指标E/指标', '日期']);
+ expect(cornerTextList).toEqual(['自定义节点A/指标E/数值', '日期']);
});
});
@@ -316,6 +318,30 @@ describe(' Tests', () => {
});
});
+ test('should export correct data for default corner text', async () => {
+ await waitFor(() => {
+ s2.setOptions({
+ cornerText: undefined,
+ });
+
+ const result = strategyCopy(s2, '\t', true);
+
+ expect(result).toMatchSnapshot();
+ });
+ });
+
+ test('should export correct data for custom corner text', async () => {
+ await waitFor(() => {
+ s2.setOptions({
+ cornerText: '自定义',
+ });
+
+ const result = strategyCopy(s2, '\t', true);
+
+ expect(result).toMatchSnapshot();
+ });
+ });
+
test('should export correct data for multi different cycle compare data', async () => {
await waitFor(() => {
/*
diff --git a/packages/s2-react/__tests__/unit/components/tooltip/__snapshots__/index-spec.tsx.snap b/packages/s2-react/__tests__/unit/components/tooltip/__snapshots__/index-spec.tsx.snap
index 7958b81bef..36062f9a4a 100644
--- a/packages/s2-react/__tests__/unit/components/tooltip/__snapshots__/index-spec.tsx.snap
+++ b/packages/s2-react/__tests__/unit/components/tooltip/__snapshots__/index-spec.tsx.snap
@@ -28,7 +28,7 @@ exports[`Tooltip Common Components Tests render TooltipHead 1`] = `
- 一二线城市,有信用卡 / 学生 / 20岁以下
+ 一二线城市,有信用卡/学生/20岁以下
`;
@@ -54,7 +54,7 @@ exports[`Tooltip Common Components Tests render TooltipSummary 1`] = `
- A人群 (总和)
+ A人群(总和)
- B人群 (总和)
+ B人群(总和)
- 差值 (总和)
+ 差值(总和)
{
});
test('render TooltipDetail', () => {
- const list = [
+ const list: TooltipDetailListItem[] = [
{
name: '20岁以下',
value: '20.5%',
@@ -173,8 +175,11 @@ describe('Tooltip Common Components Tests', () => {
});
test('render TooltipHead', () => {
- const cols = [{ name: '所在城市', value: '一二线城市' }];
- const rows = [
+ const cols: TooltipDetailListItem[] = [
+ { name: '所在城市', value: '一二线城市' },
+ ];
+
+ const rows: TooltipDetailListItem[] = [
{ name: '类别', value: '有信用卡' },
{ name: '职业', value: '学生' },
{ name: '年龄分布', value: '20岁以下' },
@@ -185,11 +190,11 @@ describe('Tooltip Common Components Tests', () => {
);
expect(asFragment()).toMatchSnapshot();
- expect(getByText('一二线城市,有信用卡 / 学生 / 20岁以下')).toBeTruthy();
+ expect(getByText('一二线城市,有信用卡/学生/20岁以下')).toBeTruthy();
});
test('render TooltipSummary', () => {
- const summaries = [
+ const summaries: TooltipSummaryOptions[] = [
{ name: 'A人群', selectedData: Array(30), value: '495.48 %' },
{ name: 'B人群', selectedData: Array(30), value: '494.52%' },
{ name: '差值', selectedData: Array(30), value: '+381%' },
diff --git a/packages/s2-react/__tests__/unit/utils/__snapshots__/build-table-hierarchy-spec.tsx.snap b/packages/s2-react/__tests__/unit/utils/__snapshots__/build-table-hierarchy-spec.tsx.snap
deleted file mode 100644
index 36ce2b1f24..0000000000
--- a/packages/s2-react/__tests__/unit/utils/__snapshots__/build-table-hierarchy-spec.tsx.snap
+++ /dev/null
@@ -1,668 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`buildTableHierarchy should generate nodes and hierarchy correctly 1`] = `
-Object {
- "belongsCell": undefined,
- "children": Array [
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "$$series_number$$",
- "height": 0,
- "id": "root[&]序号",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "$$series_number$$",
- "label": "序号",
- "level": 0,
- "padding": 0,
- "query": Object {
- "$$series_number$$": "序号",
- },
- "rowIndex": 0,
- "seriesNumberWidth": undefined,
- "value": "序号",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "province",
- "height": 0,
- "id": "root[&]省份",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "province",
- "label": "省份",
- "level": 0,
- "padding": 0,
- "query": Object {
- "province": "省份",
- },
- "rowIndex": 1,
- "seriesNumberWidth": undefined,
- "value": "省份",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "city",
- "height": 0,
- "id": "root[&]城市",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "city",
- "label": "城市",
- "level": 0,
- "padding": 0,
- "query": Object {
- "city": "城市",
- },
- "rowIndex": 2,
- "seriesNumberWidth": undefined,
- "value": "城市",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "type",
- "height": 0,
- "id": "root[&]类别",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "type",
- "label": "类别",
- "level": 0,
- "padding": 0,
- "query": Object {
- "type": "类别",
- },
- "rowIndex": 3,
- "seriesNumberWidth": undefined,
- "value": "类别",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "sub_type",
- "height": 0,
- "id": "root[&]子类别",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "sub_type",
- "label": "子类别",
- "level": 0,
- "padding": 0,
- "query": Object {
- "sub_type": "子类别",
- },
- "rowIndex": 4,
- "seriesNumberWidth": undefined,
- "value": "子类别",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "number",
- "height": 0,
- "id": "root[&]数量",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "number",
- "label": "数量",
- "level": 0,
- "padding": 0,
- "query": Object {
- "number": "数量",
- },
- "rowIndex": 5,
- "seriesNumberWidth": undefined,
- "value": "数量",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- ],
- "colIndex": -1,
- "extra": undefined,
- "field": undefined,
- "height": 0,
- "id": "root",
- "inCollapseNode": undefined,
- "isCollapsed": undefined,
- "isGrandTotals": undefined,
- "isLeaf": undefined,
- "isPivotMode": undefined,
- "isSubTotals": undefined,
- "isTotalMeasure": undefined,
- "isTotalRoot": undefined,
- "isTotals": undefined,
- "key": "",
- "label": "",
- "level": undefined,
- "padding": 0,
- "query": undefined,
- "rowIndex": undefined,
- "seriesNumberWidth": undefined,
- "value": "",
- "width": 0,
- "x": 0,
- "y": 0,
-}
-`;
-
-exports[`buildTableHierarchy should generate nodes and hierarchy correctly 2`] = `
-Hierarchy {
- "allNodesWithoutRoot": Array [
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "$$series_number$$",
- "height": 0,
- "id": "root[&]序号",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "$$series_number$$",
- "label": "序号",
- "level": 0,
- "padding": 0,
- "query": Object {
- "$$series_number$$": "序号",
- },
- "rowIndex": 0,
- "seriesNumberWidth": undefined,
- "value": "序号",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "province",
- "height": 0,
- "id": "root[&]省份",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "province",
- "label": "省份",
- "level": 0,
- "padding": 0,
- "query": Object {
- "province": "省份",
- },
- "rowIndex": 1,
- "seriesNumberWidth": undefined,
- "value": "省份",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "city",
- "height": 0,
- "id": "root[&]城市",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "city",
- "label": "城市",
- "level": 0,
- "padding": 0,
- "query": Object {
- "city": "城市",
- },
- "rowIndex": 2,
- "seriesNumberWidth": undefined,
- "value": "城市",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "type",
- "height": 0,
- "id": "root[&]类别",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "type",
- "label": "类别",
- "level": 0,
- "padding": 0,
- "query": Object {
- "type": "类别",
- },
- "rowIndex": 3,
- "seriesNumberWidth": undefined,
- "value": "类别",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "sub_type",
- "height": 0,
- "id": "root[&]子类别",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "sub_type",
- "label": "子类别",
- "level": 0,
- "padding": 0,
- "query": Object {
- "sub_type": "子类别",
- },
- "rowIndex": 4,
- "seriesNumberWidth": undefined,
- "value": "子类别",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "number",
- "height": 0,
- "id": "root[&]数量",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "number",
- "label": "数量",
- "level": 0,
- "padding": 0,
- "query": Object {
- "number": "数量",
- },
- "rowIndex": 5,
- "seriesNumberWidth": undefined,
- "value": "数量",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- ],
- "height": 0,
- "indexNode": Array [
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "$$series_number$$",
- "height": 0,
- "id": "root[&]序号",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "$$series_number$$",
- "label": "序号",
- "level": 0,
- "padding": 0,
- "query": Object {
- "$$series_number$$": "序号",
- },
- "rowIndex": 0,
- "seriesNumberWidth": undefined,
- "value": "序号",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "province",
- "height": 0,
- "id": "root[&]省份",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "province",
- "label": "省份",
- "level": 0,
- "padding": 0,
- "query": Object {
- "province": "省份",
- },
- "rowIndex": 1,
- "seriesNumberWidth": undefined,
- "value": "省份",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "city",
- "height": 0,
- "id": "root[&]城市",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "city",
- "label": "城市",
- "level": 0,
- "padding": 0,
- "query": Object {
- "city": "城市",
- },
- "rowIndex": 2,
- "seriesNumberWidth": undefined,
- "value": "城市",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "type",
- "height": 0,
- "id": "root[&]类别",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "type",
- "label": "类别",
- "level": 0,
- "padding": 0,
- "query": Object {
- "type": "类别",
- },
- "rowIndex": 3,
- "seriesNumberWidth": undefined,
- "value": "类别",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "sub_type",
- "height": 0,
- "id": "root[&]子类别",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "sub_type",
- "label": "子类别",
- "level": 0,
- "padding": 0,
- "query": Object {
- "sub_type": "子类别",
- },
- "rowIndex": 4,
- "seriesNumberWidth": undefined,
- "value": "子类别",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "number",
- "height": 0,
- "id": "root[&]数量",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "number",
- "label": "数量",
- "level": 0,
- "padding": 0,
- "query": Object {
- "number": "数量",
- },
- "rowIndex": 5,
- "seriesNumberWidth": undefined,
- "value": "数量",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- ],
- "maxLevel": 0,
- "sampleNodeForLastLevel": Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "$$series_number$$",
- "height": 0,
- "id": "root[&]序号",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "$$series_number$$",
- "label": "序号",
- "level": 0,
- "padding": 0,
- "query": Object {
- "$$series_number$$": "序号",
- },
- "rowIndex": 0,
- "seriesNumberWidth": undefined,
- "value": "序号",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- "sampleNodesForAllLevels": Array [
- Object {
- "belongsCell": undefined,
- "children": Array [],
- "colIndex": -1,
- "extra": undefined,
- "field": "$$series_number$$",
- "height": 0,
- "id": "root[&]序号",
- "inCollapseNode": undefined,
- "isCollapsed": false,
- "isGrandTotals": false,
- "isLeaf": true,
- "isPivotMode": undefined,
- "isSubTotals": false,
- "isTotalMeasure": false,
- "isTotalRoot": false,
- "isTotals": false,
- "key": "$$series_number$$",
- "label": "序号",
- "level": 0,
- "padding": 0,
- "query": Object {
- "$$series_number$$": "序号",
- },
- "rowIndex": 0,
- "seriesNumberWidth": undefined,
- "value": "序号",
- "width": 0,
- "x": 0,
- "y": 0,
- },
- ],
- "width": 0,
-}
-`;
diff --git a/packages/s2-vue/playground/App.vue b/packages/s2-vue/playground/App.vue
index 1c398a65c3..dcd6ffd98f 100644
--- a/packages/s2-vue/playground/App.vue
+++ b/packages/s2-vue/playground/App.vue
@@ -1,6 +1,6 @@