Skip to content

Commit

Permalink
test: 优化单测
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Nov 20, 2024
1 parent a9ab0b8 commit 173ffb5
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 232 deletions.
8 changes: 4 additions & 4 deletions packages/s2-core/__tests__/bugs/issue-2528-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const s2Options: S2Options = {
describe('Table Sheet Editable Formatter Tests', () => {
let s2: SpreadSheet;

beforeEach(() => {
beforeEach(async () => {
s2 = new TableSheet(getContainer(), s2DataConfig, s2Options);

s2.render();
await s2.render();
});

test('should get formatted data', () => {
Expand All @@ -36,7 +36,7 @@ describe('Table Sheet Editable Formatter Tests', () => {
expect(costValues).toEqual(['2-@', '2-@', '2-@']);
});

test('should only format data once after data edited', () => {
test('should only format data once after data edited', async () => {
const id = '0-root[&]cost';
const inputValue = 'test';

Expand All @@ -46,7 +46,7 @@ describe('Table Sheet Editable Formatter Tests', () => {
displayData[0]['cost'] = inputValue;
s2.dataSet.displayFormattedValueMap?.set(id, inputValue);

s2.render();
await s2.render();

const costValues = s2.facet
.getDataCells()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11103,206 +11103,6 @@ Array [
]
`;

exports[`SpreadSheet Multi Line Text Tests PivotSheet should update col height if corner header have more lines of text than column header 1`] = `
Array [
Object {
"actualText": "序号",
"actualTextHeight": 16,
"actualTextWidth": 25,
"height": 30,
"multiLineActualTexts": Array [
"序号",
],
"originalText": "序号",
"width": 80,
},
Object {
"actualText": "province",
"actualTextHeight": 16,
"actualTextWidth": 51,
"height": 30,
"multiLineActualTexts": Array [
"province",
],
"originalText": "province",
"width": 179.5,
},
Object {
"actualText": "城市城市城市",
"actualTextHeight": 48,
"actualTextWidth": 75,
"height": 30,
"multiLineActualTexts": Array [
"城市",
"城市",
"城市",
],
"originalText": "城市
城市
城市",
"width": 179.5,
},
Object {
"actualText": "类型类型类型类型",
"actualTextHeight": 64,
"actualTextWidth": 100,
"height": 30,
"multiLineActualTexts": Array [
"类型",
"类型",
"类型",
"类型",
],
"originalText": "类型
类型
类型
类型",
"width": 439,
},
]
`;

exports[`SpreadSheet Multi Line Text Tests PivotSheet should update col height if corner header have more lines of text than column header 2`] = `
Array [
Object {
"actualText": "1",
"actualTextHeight": 15,
"actualTextWidth": 7,
"height": 60,
"multiLineActualTexts": Array [
"1",
],
"originalText": "1",
"width": 80,
},
]
`;

exports[`SpreadSheet Multi Line Text Tests PivotSheet should update col height if corner header have more lines of text than column header 3`] = `
Array [
Object {
"actualText": "笔",
"actualTextHeight": 16,
"actualTextWidth": 13,
"height": 30,
"multiLineActualTexts": Array [
"笔",
],
"originalText": "笔",
"width": 359,
},
Object {
"actualText": "price",
"actualTextHeight": 15,
"actualTextWidth": 27,
"height": 30,
"multiLineActualTexts": Array [
"price",
],
"originalText": "price",
"width": 179.5,
},
Object {
"actualText": "cost",
"actualTextHeight": 15,
"actualTextWidth": 23,
"height": 30,
"multiLineActualTexts": Array [
"cost",
],
"originalText": "cost",
"width": 179.5,
},
]
`;

exports[`SpreadSheet Multi Line Text Tests PivotSheet should update col height if corner header have more lines of text than column header 4`] = `
Array [
Object {
"actualText": "浙江",
"actualTextHeight": 16,
"actualTextWidth": 25,
"height": 60,
"multiLineActualTexts": Array [
"浙江",
],
"originalText": "浙江",
"width": 179.5,
},
Object {
"actualText": "义乌",
"actualTextHeight": 15,
"actualTextWidth": 25,
"height": 30,
"multiLineActualTexts": Array [
"义乌",
],
"originalText": "义乌",
"width": 179.5,
},
Object {
"actualText": "杭州",
"actualTextHeight": 15,
"actualTextWidth": 25,
"height": 30,
"multiLineActualTexts": Array [
"杭州",
],
"originalText": "杭州",
"width": 179.5,
},
]
`;

exports[`SpreadSheet Multi Line Text Tests PivotSheet should update col height if corner header have more lines of text than column header 5`] = `
Array [
Object {
"actualText": "1",
"actualTextHeight": 15,
"actualTextWidth": 7,
"height": 30,
"multiLineActualTexts": Array [
"1",
],
"originalText": 1,
"width": 179.5,
},
Object {
"actualText": "1",
"actualTextHeight": 15,
"actualTextWidth": 7,
"height": 30,
"multiLineActualTexts": Array [
"1",
],
"originalText": 1,
"width": 179.5,
},
Object {
"actualText": "2",
"actualTextHeight": 15,
"actualTextWidth": 7,
"height": 30,
"multiLineActualTexts": Array [
"2",
],
"originalText": 2,
"width": 179.5,
},
Object {
"actualText": "2",
"actualTextHeight": 15,
"actualTextWidth": 7,
"height": 30,
"multiLineActualTexts": Array [
"2",
],
"originalText": 2,
"width": 179.5,
},
]
`;

exports[`SpreadSheet Multi Line Text Tests PivotSheet should use actual text height for large max line 1`] = `
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ const testDataCfg: S2DataConfig = {
describe('Empty String Values Tests', () => {
let s2: SpreadSheet;

beforeEach(() => {
beforeEach(async () => {
s2 = new PivotSheet(getContainer(), testDataCfg, s2Options);
s2.render();
await s2.render();
});

test('should get correctly first dimension values', () => {
Expand Down
Loading

0 comments on commit 173ffb5

Please sign in to comment.