From 5a99f5e49c477d8d4cee681ee11d02595589d6dc Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Thu, 14 Oct 2021 13:33:06 +0100 Subject: [PATCH] Update status in tests --- .../tools-panel/status-bar/status-bar.tsx | 2 +- .../sessions/arrow/arrow.session.spec.ts | 2 +- .../sessions/brush/brush.session.spec.ts | 2 +- .../session/sessions/draw/draw.session.spec.ts | 2 +- .../session/sessions/draw/draw.session.ts | 2 +- .../sessions/handle/handle.session.spec.ts | 2 +- .../sessions/rotate/rotate.session.spec.ts | 2 +- .../transform-single.session.spec.ts | 2 +- .../transform/transform.session.spec.ts | 2 +- .../translate/translate.session.spec.ts | 2 +- packages/tldraw/src/state/tlstate.spec.ts | 18 +++++++++--------- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/tldraw/src/components/tools-panel/status-bar/status-bar.tsx b/packages/tldraw/src/components/tools-panel/status-bar/status-bar.tsx index d2529fc1b..7a490f706 100644 --- a/packages/tldraw/src/components/tools-panel/status-bar/status-bar.tsx +++ b/packages/tldraw/src/components/tools-panel/status-bar/status-bar.tsx @@ -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 { diff --git a/packages/tldraw/src/state/session/sessions/arrow/arrow.session.spec.ts b/packages/tldraw/src/state/session/sessions/arrow/arrow.session.spec.ts index 4451168b8..1d1a36fcf 100644 --- a/packages/tldraw/src/state/session/sessions/arrow/arrow.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/arrow/arrow.session.spec.ts @@ -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() diff --git a/packages/tldraw/src/state/session/sessions/brush/brush.session.spec.ts b/packages/tldraw/src/state/session/sessions/brush/brush.session.spec.ts index 96961a5ef..7bdbeb706 100644 --- a/packages/tldraw/src/state/session/sessions/brush/brush.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/brush/brush.session.spec.ts @@ -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) }) diff --git a/packages/tldraw/src/state/session/sessions/draw/draw.session.spec.ts b/packages/tldraw/src/state/session/sessions/draw/draw.session.spec.ts index a6542120c..0ed00ee9a 100644 --- a/packages/tldraw/src/state/session/sessions/draw/draw.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/draw/draw.session.spec.ts @@ -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', () => { diff --git a/packages/tldraw/src/state/session/sessions/draw/draw.session.ts b/packages/tldraw/src/state/session/sessions/draw/draw.session.ts index 706a1b2c8..794c35e9a 100644 --- a/packages/tldraw/src/state/session/sessions/draw/draw.session.ts +++ b/packages/tldraw/src/state/session/sessions/draw/draw.session.ts @@ -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 { diff --git a/packages/tldraw/src/state/session/sessions/handle/handle.session.spec.ts b/packages/tldraw/src/state/session/sessions/handle/handle.session.spec.ts index 562e6eb2d..849cd35c0 100644 --- a/packages/tldraw/src/state/session/sessions/handle/handle.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/handle/handle.session.spec.ts @@ -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() }) diff --git a/packages/tldraw/src/state/session/sessions/rotate/rotate.session.spec.ts b/packages/tldraw/src/state/session/sessions/rotate/rotate.session.spec.ts index 280a9ec7a..54f77b4bc 100644 --- a/packages/tldraw/src/state/session/sessions/rotate/rotate.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/rotate/rotate.session.spec.ts @@ -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() diff --git a/packages/tldraw/src/state/session/sessions/transform-single/transform-single.session.spec.ts b/packages/tldraw/src/state/session/sessions/transform-single/transform-single.session.spec.ts index bc3108bfc..6cc836df5 100644 --- a/packages/tldraw/src/state/session/sessions/transform-single/transform-single.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/transform-single/transform-single.session.spec.ts @@ -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() }) diff --git a/packages/tldraw/src/state/session/sessions/transform/transform.session.spec.ts b/packages/tldraw/src/state/session/sessions/transform/transform.session.spec.ts index 5c649ebea..16a043663 100644 --- a/packages/tldraw/src/state/session/sessions/transform/transform.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/transform/transform.session.spec.ts @@ -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, diff --git a/packages/tldraw/src/state/session/sessions/translate/translate.session.spec.ts b/packages/tldraw/src/state/session/sessions/translate/translate.session.spec.ts index b8c79f3e5..e1cff8d0b 100644 --- a/packages/tldraw/src/state/session/sessions/translate/translate.session.spec.ts +++ b/packages/tldraw/src/state/session/sessions/translate/translate.session.spec.ts @@ -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]) diff --git a/packages/tldraw/src/state/tlstate.spec.ts b/packages/tldraw/src/state/tlstate.spec.ts index f3b3072a9..95316850a 100644 --- a/packages/tldraw/src/state/tlstate.spec.ts +++ b/packages/tldraw/src/state/tlstate.spec.ts @@ -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') // }) })