Skip to content

Commit 68eadaa

Browse files
test(editor): add tests for camera state reset on dispose (tldraw#8418)
Adds unit tests for the camera state reset on dispose behavior introduced in tldraw#8396. Verifies that disposing the editor while the camera is in `'moving'` state correctly resets it to `'idle'`, and that disposing while already idle is a no-op. ### Change type - [x] `other` ### Test plan ```bash cd packages/tldraw && yarn test run -t "camera state on dispose" ``` - [x] Unit tests ### Code changes | Section | LOC change | | ------- | ---------- | | Tests | +16 / -0 |
1 parent 0d7280e commit 68eadaa

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/tldraw/src/test/commands/cameraState.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,19 @@ describe('getEfficientZoomLevel', () => {
406406
})
407407
})
408408
})
409+
410+
describe('camera state on dispose', () => {
411+
it('resets to idle when disposed while camera is moving', () => {
412+
editor.setCamera({ x: 100, y: 100, z: 1 })
413+
expect(editor.getCameraState()).toBe('moving')
414+
415+
editor.dispose()
416+
expect(editor.getCameraState()).toBe('idle')
417+
})
418+
419+
it('is a no-op when disposed while camera is already idle', () => {
420+
expect(editor.getCameraState()).toBe('idle')
421+
editor.dispose()
422+
expect(editor.getCameraState()).toBe('idle')
423+
})
424+
})

0 commit comments

Comments
 (0)