diff --git a/packages/s2-core/__tests__/spreadsheet/scroll-spec.ts b/packages/s2-core/__tests__/spreadsheet/scroll-spec.ts index 27f53b9155..8671d61c67 100644 --- a/packages/s2-core/__tests__/spreadsheet/scroll-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/scroll-spec.ts @@ -462,7 +462,7 @@ describe('Scroll Tests', () => { expect((sheet.facet as any).emitScrollEvent).not.toHaveBeenCalled(); }); - test('should render correct scroll position', async () => { + test('should render correct scroll position for compact mode', async () => { s2.setOptions({ interaction: { scrollbarPosition: ScrollbarPositionType.CONTENT, @@ -480,7 +480,7 @@ describe('Scroll Tests', () => { s2.changeSheetSize(1000, 150); // 纵向滚动条 await s2.render(false); - expect(Math.floor(s2.facet.vScrollBar.getBBox().x)).toEqual(201); + expect(Math.floor(s2.facet.vScrollBar.getBBox().x)).toEqual(213); s2.setOptions({ interaction: { diff --git a/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts b/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts index 975dbb3a47..3dc217914d 100644 --- a/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/layout/col-node-width-spec.ts @@ -138,7 +138,7 @@ describe('Col width Test', () => { const colLeafNodes = s2.facet.getColLeafNodes(); // price 列,列头标签比表身数据更长 - expect(Math.round(colLeafNodes[0].width)).toBe(47); + expect(Math.round(colLeafNodes[0].width)).toBe(52); // cost 列,表身数据比列头更长(格式化) expect(Math.round(colLeafNodes[1].width)).toBe(168); }); diff --git a/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts b/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts index 06878d82d3..799b2e54cf 100644 --- a/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts @@ -88,6 +88,7 @@ jest.mock('@/sheet-type', () => { getCellRange: jest.fn().mockReturnValue({ start: 0, end: 100 }), cornerBBox: {}, getHeaderNodes: jest.fn().mockReturnValue([]), + measureTextWidth: jest.fn(), }, getCanvasElement: () => container.getContextService().getDomElement() as HTMLCanvasElement, @@ -98,6 +99,8 @@ jest.mock('@/sheet-type', () => { }, measureTextWidth: jest.fn() as unknown as SpreadSheet['measureTextWidth'], + measureTextWidthRoughly: + jest.fn() as unknown as SpreadSheet['measureTextWidthRoughly'], getSeriesNumberText: jest.fn(() => getDefaultSeriesNumberText()), }; }), diff --git a/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts b/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts index daefde8c6d..224dbf6c6d 100644 --- a/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts +++ b/packages/s2-core/__tests__/unit/facet/table-facet-spec.ts @@ -61,6 +61,7 @@ jest.mock('@/sheet-type', () => { getColNodeHeight: jest.fn(), getHeaderNodes: jest.fn().mockReturnValue([]), getCellMeta: jest.fn().mockRejectedValue({}), + measureTextWidth: jest.fn(), }, dataSet: { isEmpty: jest.fn(), diff --git a/packages/s2-core/__tests__/unit/utils/__snapshots__/merge-spec.ts.snap b/packages/s2-core/__tests__/unit/utils/__snapshots__/merge-spec.ts.snap index 05806f3497..3218784a8a 100644 --- a/packages/s2-core/__tests__/unit/utils/__snapshots__/merge-spec.ts.snap +++ b/packages/s2-core/__tests__/unit/utils/__snapshots__/merge-spec.ts.snap @@ -121,7 +121,7 @@ Object { } `; -exports[`merge test should setup correctly compact layout width type style 1`] = ` +exports[`merge test should not setup correctly compact layout width type style 1`] = ` Object { "colCell": Object { "height": 30, @@ -141,7 +141,7 @@ Object { "maxLines": 1, "textOverflow": "ellipsis", "width": 96, - "wordWrap": false, + "wordWrap": true, }, "layoutWidthType": "compact", "rowCell": Object { diff --git a/packages/s2-core/__tests__/unit/utils/merge-spec.ts b/packages/s2-core/__tests__/unit/utils/merge-spec.ts index 867c685beb..4ef0de9306 100644 --- a/packages/s2-core/__tests__/unit/utils/merge-spec.ts +++ b/packages/s2-core/__tests__/unit/utils/merge-spec.ts @@ -175,7 +175,7 @@ describe('merge test', () => { expect(setupOptions(null)).toMatchSnapshot(); }); - test('should setup correctly compact layout width type style', () => { + test('should not setup correctly compact layout width type style', () => { expect( setupOptions({ style: {