Unicode.spec.js 1016 B

12345678910111213141516171819202122232425262728293031
  1. import {
  2. isKey,
  3. } from 'handsontable/helpers/unicode';
  4. describe('Unicode helper', () => {
  5. //
  6. // Handsontable.helper.isKey
  7. //
  8. describe('isKey', () => {
  9. it('should be defined', () => {
  10. expect(isKey).toBeDefined();
  11. });
  12. it('should return true when base code is defined individually', () => {
  13. expect(isKey(39, 'ARROW_RIGHT')).toBe(true);
  14. expect(isKey('39', 'ARROW_RIGHT')).toBe(false);
  15. expect(isKey(30, 'ARROW_RIGHT')).toBe(false);
  16. });
  17. it('should return true when base code is defined many times', () => {
  18. expect(isKey(39, 'ARROW_RIGHT|ARROW_UP|ARROW_DOWN')).toBe(true);
  19. expect(isKey(38, 'ARROW_RIGHT|ARROW_UP|ARROW_DOWN')).toBe(true);
  20. expect(isKey(40, 'ARROW_RIGHT|ARROW_UP|ARROW_DOWN')).toBe(true);
  21. expect(isKey(37, 'ARROW_RIGHT|ARROW_UP|ARROW_BOTTOM')).toBe(false);
  22. expect(isKey('39', 'ARROW_RIGHT|ARROW_UP|ARROW_BOTTOM')).toBe(false);
  23. expect(isKey(116, 'ARROW_RIGHT|ARROW_UP|ARROW_BOTTOM')).toBe(false);
  24. });
  25. });
  26. });