Skip to content

Commit

Permalink
test: 单测修复
Browse files Browse the repository at this point in the history
  • Loading branch information
wjgogogo committed May 7, 2024
1 parent 5ef0174 commit 4ab8030
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@ describe('PivotSheet Brush Selection Scroll Tests', () => {
);

await s2.render();
await sleep(20); // wait for anthor loop;
await sleep(20); // wait for another loop;

const rowCell = s2.facet.getRowCells()[0];

s2.getCell = jest.fn(() => rowCell);

s2.emit(S2Event.ROW_CELL_MOUSE_DOWN, {
target: rowCell,
x: 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/s2-core/__tests__/spreadsheet/table-sheet-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('TableSheet normal spec', () => {
columnNodes = s2.facet.getColNodes();
const endCellWidth = columnNodes[columnNodes.length - 1].width;

expect(Math.floor(endCellWidth - startCellWidth)).toBe(140);
expect(endCellWidth - startCellWidth).toBeGreaterThanOrEqual(resizeLength);
});

test('should render link shape', async () => {
Expand Down
12 changes: 8 additions & 4 deletions packages/s2-core/__tests__/unit/utils/text-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {
isUnchangedValue,
} from '@/utils/text';

const isHD = window.devicePixelRatio >= 2;

describe('Text Utils Tests', () => {
const font: TextTheme = {
fontFamily: 'Roboto',
Expand All @@ -25,7 +23,13 @@ describe('Text Utils Tests', () => {

beforeEach(() => {
measureTextWidth = createPivotSheet(
{},
{
transformCanvasConfig() {
return {
devicePixelRatio: 2,
};
},
},
{ useSimpleData: true },
).measureTextWidth;
});
Expand All @@ -37,7 +41,7 @@ describe('Text Utils Tests', () => {
test('should get correct text width', () => {
const width = measureTextWidth('test', font);

expect(Math.floor(width)).toEqual(isHD ? 21 : 16);
expect(Math.floor(width)).toEqual(21);
});
});

Expand Down

0 comments on commit 4ab8030

Please sign in to comment.