Skip to content

Commit 967bb92

Browse files
committed
fix: add shared geometry mock to selection tests
1 parent f3a02ae commit 967bb92

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

packages/core/src/behaviors/selection.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ import type { BehaviorContext, Selection } from '../editing-session'
22
import { describe, expect, it, vi } from 'vitest'
33
import { selectionMiddleware } from './selection'
44

5+
const geometry: BehaviorContext['geometry'] = {
6+
getPageGeometry: () => ({
7+
pageOffset: { x: 0, y: 0 },
8+
zoom: 1,
9+
scroll: { x: 0, y: 0 },
10+
documentUnit: 'px',
11+
}),
12+
screenToDocument: point => point,
13+
documentToScreen: point => point,
14+
documentToLocal: point => point,
15+
localToDocument: point => point,
16+
getSelectionRects: () => [],
17+
}
18+
519
function createContext(hit: Selection | null): BehaviorContext {
620
let currentSelection: Selection | null = {
721
type: 'table.cell',
@@ -31,9 +45,7 @@ function createContext(hit: Selection | null): BehaviorContext {
3145
hitTest: () => hit,
3246
},
3347
tx: {} as BehaviorContext['tx'],
34-
geometry: {
35-
documentToLocal: point => point,
36-
} as BehaviorContext['geometry'],
48+
geometry,
3749
selectionStore: {
3850
get selection() {
3951
return currentSelection

0 commit comments

Comments
 (0)