Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

draw.session.spec.ts 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { TLDrawState } from '~state'
  2. import { mockDocument } from '~test'
  3. import { ColorStyle, DashStyle, SizeStyle, TLDrawShapeType, TLDrawStatus } from '~types'
  4. describe('Draw session', () => {
  5. const tlstate = new TLDrawState()
  6. it('begins, updates and completes session', () => {
  7. tlstate.loadDocument(mockDocument)
  8. expect(tlstate.getShape('draw1')).toBe(undefined)
  9. tlstate
  10. .createShapes({
  11. id: 'draw1',
  12. parentId: 'page1',
  13. name: 'Draw',
  14. childIndex: 5,
  15. type: TLDrawShapeType.Draw,
  16. point: [32, 32],
  17. points: [[0, 0]],
  18. style: {
  19. dash: DashStyle.Draw,
  20. size: SizeStyle.Medium,
  21. color: ColorStyle.Blue,
  22. },
  23. })
  24. .select('draw1')
  25. .startDrawSession('draw1', [0, 0])
  26. .updateDrawSession([10, 10], 0.5)
  27. .completeSession()
  28. expect(tlstate.appState.status.current).toBe(TLDrawStatus.Idle)
  29. })
  30. it('does, undoes and redoes', () => {
  31. expect(tlstate.getShape('draw1')).toBeTruthy()
  32. tlstate.undo()
  33. expect(tlstate.getShape('draw1')).toBe(undefined)
  34. tlstate.redo()
  35. expect(tlstate.getShape('draw1')).toBeTruthy()
  36. })
  37. })