Skip to content

Commit

Permalink
test: 修复单测
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Nov 13, 2024
1 parent db3d5f4 commit 7af4c0c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/s2-core/__tests__/spreadsheet/scroll-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
3 changes: 3 additions & 0 deletions packages/s2-core/__tests__/unit/facet/pivot-facet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()),
};
}),
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/__tests__/unit/facet/table-facet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -141,7 +141,7 @@ Object {
"maxLines": 1,
"textOverflow": "ellipsis",
"width": 96,
"wordWrap": false,
"wordWrap": true,
},
"layoutWidthType": "compact",
"rowCell": Object {
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/unit/utils/merge-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 7af4c0c

Please sign in to comment.