Event.spec.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {isLeftClick, isRightClick} from 'handsontable/helpers/dom/event';
  2. describe('DomEvent helper', () => {
  3. //
  4. // Handsontable.dom.isLeftClick
  5. //
  6. describe('isLeftClick', () => {
  7. it('should return true for valid mouse events', () => {
  8. expect(isLeftClick({button: 0})).toBe(true);
  9. });
  10. it('should return false for invalid mouse events', () => {
  11. expect(isLeftClick({button: '0'})).toBe(false);
  12. expect(isLeftClick({button: 1})).toBe(false);
  13. expect(isLeftClick({button: 2})).toBe(false);
  14. expect(isLeftClick({button: 3})).toBe(false);
  15. expect(isLeftClick({button: null})).toBe(false);
  16. expect(isLeftClick({button: void 0})).toBe(false);
  17. expect(isLeftClick({})).toBe(false);
  18. });
  19. });
  20. //
  21. // Handsontable.dom.isRightClick
  22. //
  23. describe('isRightClick', () => {
  24. it('should return true for valid mouse events', () => {
  25. expect(isRightClick({button: 2})).toBe(true);
  26. });
  27. it('should return false for invalid mouse events', () => {
  28. expect(isRightClick({button: '0'})).toBe(false);
  29. expect(isRightClick({button: 1})).toBe(false);
  30. expect(isRightClick({button: -2})).toBe(false);
  31. expect(isRightClick({button: 3})).toBe(false);
  32. expect(isRightClick({button: null})).toBe(false);
  33. expect(isRightClick({button: void 0})).toBe(false);
  34. expect(isRightClick({})).toBe(false);
  35. });
  36. });
  37. });