HandToolSpec.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {
  2. bootstrapDiagram,
  3. inject
  4. } from 'test/TestHelper';
  5. import { createCanvasEvent as canvasEvent } from '../../../util/MockEvents';
  6. import handToolModule from 'lib/features/hand-tool';
  7. import draggingModule from 'lib/features/dragging';
  8. describe('features/hand-tool', function() {
  9. beforeEach(bootstrapDiagram({ modules: [ handToolModule, draggingModule ] }));
  10. var rootShape, childShape;
  11. beforeEach(inject(function(dragging) {
  12. dragging.setOptions({ manual: true });
  13. }));
  14. beforeEach(inject(function(canvas, elementFactory) {
  15. rootShape = elementFactory.createRoot({
  16. id: 'root'
  17. });
  18. canvas.setRootElement(rootShape);
  19. childShape = elementFactory.createShape({
  20. id: 'child',
  21. x: 110, y: 110, width: 50, height: 100
  22. });
  23. canvas.addShape(childShape, rootShape);
  24. }));
  25. describe('general', function() {
  26. it('should not move element', inject(function(canvas, handTool, dragging) {
  27. // given
  28. var position = {
  29. x: childShape.x,
  30. y: childShape.y
  31. };
  32. // when
  33. handTool.activateMove(canvasEvent({ x: 150, y: 150 }));
  34. dragging.move(canvasEvent({ x: 300, y: 300 }));
  35. dragging.end();
  36. // then
  37. expect(childShape.x).to.equal(position.x);
  38. expect(childShape.y).to.equal(position.y);
  39. }));
  40. });
  41. });