HoverFixSpec.js 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {
  2. bootstrapDiagram,
  3. inject
  4. } from 'test/TestHelper';
  5. import { createCanvasEvent as canvasEvent } from '../../../util/MockEvents';
  6. import dragModule from 'lib/features/dragging';
  7. describe('features/dragging - HoverFix', function() {
  8. beforeEach(bootstrapDiagram({ modules: [ dragModule ] }));
  9. beforeEach(inject(function(canvas) {
  10. canvas.addShape({ id: 'shape', x: 10, y: 10, width: 50, height: 50 });
  11. }));
  12. describe('behavior', function() {
  13. beforeEach(inject(function(dragging) {
  14. dragging.setOptions({ manual: true });
  15. }));
  16. it('should ensure hover', inject(function(dragging, hoverFix) {
  17. // given
  18. var fixed = false;
  19. hoverFix.ensureHover = function(event) {
  20. fixed = true;
  21. };
  22. // when
  23. dragging.init(canvasEvent({ x: 10, y: 10 }), 'foo');
  24. dragging.move(canvasEvent({ x: 30, y: 20 }));
  25. dragging.move(canvasEvent({ x: 5, y: 10 }));
  26. // then
  27. expect(fixed).to.be.true;
  28. }));
  29. });
  30. });