openpencil/packages/core/tests/editor/navigation-lifecycle.test.ts
Danila Poyarkov 87bff8620c
test(core): move the editor suite into the package (#792)
The 54 editor engine tests move to packages/core/tests/editor with their helpers, importing Core's public subpaths or source modules relatively. The package gains test and typecheck scripts; the first type check fixed nullable lookups, stale imports, and renderer doubles, and graph events now declare the GraphEventRenderer surface they invalidate. The engine baseline drops to 534 files.
2026-09-30 10:22:42 +04:00

30 lines
1,004 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { createEditor } from '@open-pencil/core/editor'
describe('navigation lifecycle', () => {
test('increments generation when a new gesture starts but not during one gesture', () => {
const editor = createEditor()
const events: Array<{ phase: string; generation: number }> = []
const off = editor.onEditorEvent('navigation:changed', (navigation) => {
events.push({ phase: navigation.phase, generation: navigation.generation })
})
editor.setNavigationPhase('zoom', 10)
editor.setNavigationPhase('zoom', 20)
editor.setNavigationPhase('settling', 20)
editor.setNavigationPhase('zoom', 30)
editor.setNavigationPhase('idle', 40)
expect(events).toEqual([
{ phase: 'zoom', generation: 1 },
{ phase: 'zoom', generation: 1 },
{ phase: 'settling', generation: 1 },
{ phase: 'zoom', generation: 2 },
{ phase: 'idle', generation: 2 }
])
off()
editor.dispose()
})
})