Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 回退生成 nodeId 时对 extra 字段的格式化 #2546

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,30 @@ exports[`SpreadSheet Custom Dataset Tests should render custom data set 1`] = `
Array [
Object {
"id": "province",
"value": "test",
},
Object {
"id": "city",
"value": "test",
},
Object {
"id": "type",
"value": "test",
},
Object {
"id": "root[&]test",
"value": "test",
"id": "root[&]浙江",
},
Object {
"id": "root[&]test[&]test",
"value": "test",
"id": "root[&]浙江[&]义乌",
},
Object {
"id": "root[&]test",
"value": "test",
"id": "root[&]浙江[&]杭州",
},
Object {
"id": "root[&]test[&]test",
"value": "test",
"id": "root[&]笔",
},
Object {
"id": "root[&]test[&]test",
"value": "test",
"id": "root[&]笔[&]price",
},
Object {
"id": "root[&]笔[&]cost",
},
]
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SpreadSheet Custom Value Order Tests should use custom grid pivot dataSet 1`] = `
Array [
Object {
"id": "root[&]家具[&]number[&]桌子",
"query": Object {
"$$extra$$": "number",
"sub_type": "桌子",
"type": "家具",
},
"value": "桌子",
},
Object {
"id": "root[&]家具[&]number[&]沙发",
"query": Object {
"$$extra$$": "number",
"sub_type": "沙发",
"type": "家具",
},
"value": "沙发",
},
Object {
"id": "root[&]办公用品[&]number[&]笔",
"query": Object {
"$$extra$$": "number",
"sub_type": "笔",
"type": "办公用品",
},
"value": "笔",
},
Object {
"id": "root[&]办公用品[&]number[&]纸张",
"query": Object {
"$$extra$$": "number",
"sub_type": "纸张",
"type": "办公用品",
},
"value": "纸张",
},
]
`;
10 changes: 3 additions & 7 deletions packages/s2-core/__tests__/spreadsheet/custom-dataset-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pick } from 'lodash';
import { createPivotSheet } from 'tests/util/helpers';
import { Node, PivotDataSet } from '../../src';
import { PivotDataSet } from '../../src';
import { pickMap } from '../util/fp';

describe('SpreadSheet Custom Dataset Tests', () => {
class CustomDataSet extends PivotDataSet {
Expand All @@ -9,18 +9,14 @@ describe('SpreadSheet Custom Dataset Tests', () => {
}
}

const mapNodes = (nodes: Node[]) => {
return nodes.map((node) => pick(node, ['id', 'value']));
};

test('should render custom data set', async () => {
const s2 = createPivotSheet({
dataSet: (spreadsheet) => new CustomDataSet(spreadsheet),
});

await s2.render();

const headerNodes = mapNodes(s2.facet.getHeaderNodes());
const headerNodes = pickMap(['id', 'values'])(s2.facet.getHeaderNodes());

expect(headerNodes).toMatchSnapshot();
});
Expand Down
Loading
Loading