Skip to content

Commit

Permalink
Merge branch 'master' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed Dec 8, 2023
2 parents 1a05be9 + 51bc110 commit 365371a
Show file tree
Hide file tree
Showing 15 changed files with 862 additions and 31 deletions.

Large diffs are not rendered by default.

80 changes: 76 additions & 4 deletions packages/s2-core/__tests__/unit/data-set/table-data-set-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('Table Mode Dataset Test', () => {
});

describe('test for query data', () => {
test('getCellData function', () => {
test('#getCellData', () => {
expect(
dataSet.getCellData({
query: { rowIndex: 0 },
Expand All @@ -128,7 +128,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 0,
col: 'city',
field: 'city',
},
}),
).toEqual('杭州市');
Expand All @@ -137,7 +137,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 2,
col: 'number',
field: 'number',
},
}),
).toEqual(3877);
Expand All @@ -146,10 +146,82 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 5,
col: 'sub_type',
field: 'sub_type',
},
}),
).toEqual('沙发');
});

test('#getMultiData by empty query', () => {
expect(dataSet.getMultiData(null)).toMatchSnapshot();
expect(dataSet.getMultiData(null)).toEqual(dataSet.getMultiData({}));
});

test('#getMultiData by rowIndex query', () => {
expect(
dataSet.getMultiData({
rowIndex: 0,
}),
).toMatchInlineSnapshot(`
Array [
Object {
"city": "杭州市",
"number": 7789,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
]
`);

expect(
dataSet.getMultiData({
rowIndex: -1,
}),
).toMatchSnapshot();
});

test('#getMultiData by field query', () => {
expect(
dataSet.getMultiData({
field: 'city',
}),
).toMatchSnapshot();

expect(
dataSet.getMultiData({
field: 'number',
}),
).toMatchSnapshot();

expect(
dataSet.getMultiData({
field: 'sub_type',
}),
).toMatchSnapshot();
});

test('#getMultiData by field and rowIndex query', () => {
expect(
dataSet.getMultiData({
field: 'city',
rowIndex: 0,
}),
).toEqual(['杭州市']);

expect(
dataSet.getMultiData({
field: 'number',
rowIndex: 2,
}),
).toEqual([3877]);

expect(
dataSet.getMultiData({
field: 'sub_type',
rowIndex: 3,
}),
).toEqual(['桌子']);
});
});
});
16 changes: 8 additions & 8 deletions packages/s2-core/__tests__/unit/dataset/table-dataset-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 0,
col: 'city',
field: 'city',
},
}),
).toEqual('杭州市');
Expand All @@ -66,7 +66,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 2,
col: 'number',
field: 'number',
},
}),
).toEqual(3877);
Expand All @@ -75,7 +75,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 5,
col: 'sub_type',
field: 'sub_type',
},
}),
).toEqual('沙发');
Expand All @@ -93,7 +93,7 @@ describe('Table Mode Dataset Test', () => {
expect(
emptyDataSet.getCellData({
query: {
col: 'sub_type',
field: 'sub_type',
rowIndex: 0,
},
}),
Expand All @@ -116,7 +116,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 0,
col: 'city',
field: 'city',
},
}),
).toEqual('成都市');
Expand All @@ -136,7 +136,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 0,
col: 'city',
field: 'city',
},
}),
).toEqual('杭州市');
Expand All @@ -158,7 +158,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 0,
col: 'city',
field: 'city',
},
}),
).toEqual('成都市');
Expand All @@ -178,7 +178,7 @@ describe('Table Mode Dataset Test', () => {
dataSet.getCellData({
query: {
rowIndex: 0,
col: 'number',
field: 'number',
},
}),
).toEqual(245);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('Interaction Hover Tests', () => {
const mockTooltipParams = [
[{ value: undefined, valueField: undefined }],
{
enableFormat: true,
enterable: true,
hideSummary: true,
isTotals: undefined,
Expand All @@ -49,6 +50,7 @@ describe('Interaction Hover Tests', () => {
},
getActualText: () => ELLIPSIS_SYMBOL,
getFieldValue: () => '',
isTextOverflowing: () => true,
cellType: 'dataCell',
} as any);

Expand Down Expand Up @@ -339,6 +341,7 @@ describe('Interaction Hover Tests', () => {
},
getActualText: () => 'test',
getFieldValue: () => 'test',
isTextOverflowing: jest.fn(() => false),
cellType: 'dataCell',
} as any);

Expand Down
154 changes: 154 additions & 0 deletions packages/s2-core/__tests__/unit/utils/tooltip-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
createFakeSpreadSheet,
createMockCellInfo,
createPivotSheet,
createTableSheet,
getContainer,
} from 'tests/util/helpers';
import type { BBox } from '@antv/g-canvas';
Expand Down Expand Up @@ -795,6 +796,159 @@ describe('Tooltip Utils Tests', () => {
},
);
});

describe('Tooltip Get Data Tests For TableSheet', () => {
beforeEach(() => {
s2 = createTableSheet(
{ showSeriesNumber: true },
{ useSimpleData: false },
);
s2.render();
});

afterEach(() => {
s2.destroy();
});

test('should get correctly summaries of selected col cell', () => {
const typeColCell = s2.getColumnLeafNodes()[1].belongsCell;
const subTypeColCell = s2.getColumnLeafNodes()[2].belongsCell;

expect(getMockTooltipData(typeColCell)).toMatchInlineSnapshot(`
Object {
"description": "类别说明。。",
"details": null,
"headInfo": null,
"infos": undefined,
"interpretation": undefined,
"name": undefined,
"summaries": Array [
Object {
"name": "",
"selectedData": Array [
"家具",
"家具",
"家具",
"家具",
"家具",
"家具",
"家具",
"家具",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"家具",
"家具",
"家具",
"家具",
"家具",
"家具",
"家具",
"家具",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
"办公用品",
],
"value": "",
},
],
"tips": undefined,
}
`);
expect(getMockTooltipData(subTypeColCell)).toMatchInlineSnapshot(`
Object {
"description": "子类别说明。。",
"details": null,
"headInfo": null,
"infos": undefined,
"interpretation": undefined,
"name": undefined,
"summaries": Array [
Object {
"name": "",
"selectedData": Array [
"桌子",
"桌子",
"桌子",
"桌子",
"沙发",
"沙发",
"沙发",
"沙发",
"笔",
"笔",
"笔",
"笔",
"纸张",
"纸张",
"纸张",
"纸张",
"桌子",
"桌子",
"桌子",
"桌子",
"沙发",
"沙发",
"沙发",
"沙发",
"笔",
"笔",
"笔",
"笔",
"纸张",
"纸张",
"纸张",
"纸张",
],
"value": "",
},
],
"tips": undefined,
}
`);
});

test('should get correctly summaries of selected series number cell', () => {
const seriesCell = s2.interaction.getPanelGroupAllDataCells()[0];

expect(getMockTooltipData(seriesCell)).toMatchInlineSnapshot(`
Object {
"description": undefined,
"details": null,
"headInfo": null,
"infos": undefined,
"interpretation": undefined,
"name": undefined,
"summaries": Array [
Object {
"name": "",
"selectedData": Array [
Object {
"city": "杭州市",
"number": 7789,
"province": "浙江省",
"sub_type": "桌子",
"type": "家具",
},
],
"value": "",
},
],
"tips": undefined,
}
`);
});
});
});

test('should set container style', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/__tests__/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export const createMockCellInfo = (
getFieldValue: jest.fn(),
hideInteractionShape: jest.fn(),
updateByState: jest.fn(),
isTextOverflowing: jest.fn(),
} as unknown as S2CellType;

return {
Expand Down
Loading

0 comments on commit 365371a

Please sign in to comment.