Update status in tests
This commit is contained in:
parent
70cd3262f5
commit
5a99f5e49c
11 changed files with 19 additions and 19 deletions
|
@ -3,7 +3,7 @@ import { useTLDrawContext } from '~hooks'
|
|||
import type { Data } from '~types'
|
||||
import css from '~styles'
|
||||
|
||||
const statusSelector = (s: Data) => s.appState.status.current
|
||||
const statusSelector = (s: Data) => s.appState.status
|
||||
const activeToolSelector = (s: Data) => s.appState.activeTool
|
||||
|
||||
export function StatusBar(): JSX.Element | null {
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('Arrow session', () => {
|
|||
expect(binding.fromId).toBe('arrow1')
|
||||
expect(binding.toId).toBe('target1')
|
||||
expect(binding.meta.handleId).toBe('start')
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.getShape('arrow1').handles?.start.bindingId).toBe(binding.id)
|
||||
|
||||
tlstate.undo()
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('Brush session', () => {
|
|||
.startSession(SessionType.Brush, [-10, -10])
|
||||
.updateSession([10, 10])
|
||||
.completeSession()
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.selectedIds.length).toBe(1)
|
||||
})
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('Draw session', () => {
|
|||
.updateSession([10, 10, 0.5])
|
||||
.completeSession()
|
||||
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
})
|
||||
|
||||
it('does, undoes and redoes', () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Utils } from '@tldraw/core'
|
||||
import { Vec } from '@tldraw/vec'
|
||||
import { Data, DrawShape, Session, SessionType, TLDrawStatus } from '~types'
|
||||
import { Data, Session, SessionType, TLDrawStatus } from '~types'
|
||||
import { TLDR } from '~state/tldr'
|
||||
|
||||
export class DrawSession implements Session {
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('Handle session', () => {
|
|||
.updateSession([10, 10])
|
||||
.completeSession()
|
||||
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
|
||||
tlstate.undo().redo()
|
||||
})
|
||||
|
|
|
@ -34,7 +34,7 @@ describe('Rotate session', () => {
|
|||
|
||||
tlstate.completeSession()
|
||||
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
|
||||
tlstate.undo()
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('Transform single session', () => {
|
|||
.updateSession([10, 10])
|
||||
.completeSession()
|
||||
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
|
||||
tlstate.undo().redo()
|
||||
})
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('Transform session', () => {
|
|||
.updateSession([10, 10])
|
||||
.completeSession()
|
||||
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
|
||||
expect(getShapeBounds(tlstate, 'rect1')).toMatchObject({
|
||||
minX: 10,
|
||||
|
|
|
@ -16,7 +16,7 @@ describe('Translate session', () => {
|
|||
|
||||
tlstate.completeSession()
|
||||
|
||||
expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
|
||||
expect(tlstate.appState.status).toBe(TLDrawStatus.Idle)
|
||||
|
||||
expect(tlstate.getShape('rect1').point).toStrictEqual([5, 5])
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ describe('TLDrawState', () => {
|
|||
tlstate.loadDocument(mockDocument).deselectAll()
|
||||
tlu.clickShape('rect1')
|
||||
expect(tlstate.selectedIds).toStrictEqual(['rect1'])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
it('selects and deselects a shape', () => {
|
||||
|
@ -118,7 +118,7 @@ describe('TLDrawState', () => {
|
|||
tlu.clickShape('rect1')
|
||||
tlu.clickCanvas()
|
||||
expect(tlstate.selectedIds).toStrictEqual([])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
it('selects multiple shapes', () => {
|
||||
|
@ -126,7 +126,7 @@ describe('TLDrawState', () => {
|
|||
tlu.clickShape('rect1')
|
||||
tlu.clickShape('rect2', { shiftKey: true })
|
||||
expect(tlstate.selectedIds).toStrictEqual(['rect1', 'rect2'])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
it('shift-selects to deselect shapes', () => {
|
||||
|
@ -135,7 +135,7 @@ describe('TLDrawState', () => {
|
|||
tlu.clickShape('rect2', { shiftKey: true })
|
||||
tlu.clickShape('rect2', { shiftKey: true })
|
||||
expect(tlstate.selectedIds).toStrictEqual(['rect1'])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
it('clears selection when clicking bounds', () => {
|
||||
|
@ -162,7 +162,7 @@ describe('TLDrawState', () => {
|
|||
tlstate.loadDocument(mockDocument).deselectAll()
|
||||
tlu.clickShape('rect1', { ctrlKey: true })
|
||||
expect(tlstate.selectedIds).toStrictEqual([])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
it.todo('deletes shapes if cancelled during creating')
|
||||
|
@ -191,7 +191,7 @@ describe('TLDrawState', () => {
|
|||
tlu.clickShape('rect2', { shiftKey: true })
|
||||
tlu.clickShape('rect2')
|
||||
expect(tlstate.selectedIds).toStrictEqual(['rect2'])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
it('single-selects shape in selection on pointerup only', () => {
|
||||
|
@ -202,17 +202,17 @@ describe('TLDrawState', () => {
|
|||
expect(tlstate.selectedIds).toStrictEqual(['rect1', 'rect2'])
|
||||
tlu.stopPointing('rect2')
|
||||
expect(tlstate.selectedIds).toStrictEqual(['rect2'])
|
||||
expect(tlstate.appState.status.current).toBe('idle')
|
||||
expect(tlstate.appState.status).toBe('idle')
|
||||
})
|
||||
|
||||
// it('selects shapes if shift key is lifted before pointerup', () => {
|
||||
// tlstate.deselectAll()
|
||||
// tlu.clickShape('rect1')
|
||||
// tlu.pointShape('rect2', { shiftKey: true })
|
||||
// expect(tlstate.appState.status.current).toBe('pointingBounds')
|
||||
// expect(tlstate.appState.status).toBe('pointingBounds')
|
||||
// tlu.stopPointing('rect2')
|
||||
// expect(tlstate.selectedIds).toStrictEqual(['rect2'])
|
||||
// expect(tlstate.appState.status.current).toBe('idle')
|
||||
// expect(tlstate.appState.status).toBe('idle')
|
||||
// })
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue