You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

draw.test.ts 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { ShapeType } from 'types'
  2. import TestState from '../test-utils'
  3. describe('draw shape', () => {
  4. const tt = new TestState()
  5. tt.resetDocumentState().save()
  6. describe('creating draws', () => {
  7. it('creates shape', () => {
  8. tt.reset().restore().send('SELECTED_DRAW_TOOL')
  9. expect(tt.state.isIn('draw.creating')).toBe(true)
  10. tt.startClick('canvas').movePointerBy([100, 100]).stopClick('canvas')
  11. const id = tt.getSortedPageShapeIds()[0]
  12. tt.assertShapeType(id, ShapeType.Draw)
  13. })
  14. it('creates shapes when pointing a shape', () => {
  15. tt.reset().restore().send('SELECTED_DRAW_TOOL').send('TOGGLED_TOOL_LOCK')
  16. tt.startClick('canvas').movePointerBy([100, 100]).stopClick('canvas')
  17. tt.startClick('canvas').movePointerBy([-200, 100]).stopClick('canvas')
  18. expect(tt.getSortedPageShapeIds()).toHaveLength(2)
  19. })
  20. it('creates shapes when shape locked', () => {
  21. tt.reset()
  22. .restore()
  23. .createShape(
  24. {
  25. type: ShapeType.Rectangle,
  26. point: [0, 0],
  27. size: [100, 100],
  28. childIndex: 1,
  29. },
  30. 'rect1'
  31. )
  32. .send('SELECTED_DRAW_TOOL')
  33. tt.startClick('rect1').movePointerBy([100, 100]).stopClick('canvas')
  34. expect(tt.getSortedPageShapeIds()).toHaveLength(2)
  35. })
  36. it('cancels shape while creating', () => {
  37. // TODO
  38. null
  39. })
  40. })
  41. it('moves shape', () => {
  42. // TODO
  43. null
  44. })
  45. it('rotates shape', () => {
  46. // TODO
  47. null
  48. })
  49. it('rotates shape in a group', () => {
  50. // TODO
  51. null
  52. })
  53. it('measures shape bounds', () => {
  54. // TODO
  55. null
  56. })
  57. it('measures shape rotated bounds', () => {
  58. // TODO
  59. null
  60. })
  61. it('transforms single shape', () => {
  62. // TODO
  63. null
  64. })
  65. it('transforms in a group', () => {
  66. // TODO
  67. null
  68. })
  69. /* -------------------- Specific -------------------- */
  70. it('closes the shape when the start and end points are near enough', () => {
  71. // TODO
  72. null
  73. })
  74. it('remains closed after resizing up', () => {
  75. // TODO
  76. null
  77. })
  78. })