mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-04 13:07:55 +00:00 
			
		
		
		
	* fix: Resolve and go next keyboard shortcuts doesn't work * refactor: use buildHotKeys instead of hasPressedCommandPlusAltAndEKey * feat: install tinykeys * refactor: use tinykeys * test: update buildKeyEvents * fix: remove stray import * feat: handle action list globally * feat: allow configuring `allowOnFocusedInput` * chore: Navigate chat list item * chore: Navigate dashboard * feat: Navigate editor top panel * feat: Toggle file upload * chore: More keyboard shortcuts * chore: Update mention selection mixin * chore: Phone input * chore: Clean up * chore: Clean up * chore: Dropdown and editor * chore: Enter key to send and clean up * chore: Rename mixin * chore: Review fixes * chore: Removed unused shortcut from modal * fix: Specs --------- Co-authored-by: iamsivin <iamsivin@gmail.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
		
			
				
	
	
		
			68 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import {
 | 
						|
  isEnter,
 | 
						|
  isEscape,
 | 
						|
  hasPressedShift,
 | 
						|
  hasPressedCommand,
 | 
						|
  isActiveElementTypeable,
 | 
						|
} from '../KeyboardHelpers';
 | 
						|
 | 
						|
describe('#KeyboardHelpers', () => {
 | 
						|
  describe('#isEnter', () => {
 | 
						|
    it('return correct values', () => {
 | 
						|
      expect(isEnter({ key: 'Enter' })).toEqual(true);
 | 
						|
    });
 | 
						|
  });
 | 
						|
 | 
						|
  describe('#isEscape', () => {
 | 
						|
    it('return correct values', () => {
 | 
						|
      expect(isEscape({ key: 'Escape' })).toEqual(true);
 | 
						|
    });
 | 
						|
  });
 | 
						|
 | 
						|
  describe('#hasPressedShift', () => {
 | 
						|
    it('return correct values', () => {
 | 
						|
      expect(hasPressedShift({ shiftKey: true })).toEqual(true);
 | 
						|
    });
 | 
						|
  });
 | 
						|
 | 
						|
  describe('#hasPressedCommand', () => {
 | 
						|
    it('return correct values', () => {
 | 
						|
      expect(hasPressedCommand({ metaKey: true })).toEqual(true);
 | 
						|
    });
 | 
						|
  });
 | 
						|
});
 | 
						|
 | 
						|
describe('isActiveElementTypeable', () => {
 | 
						|
  it('should return true if the active element is an input element', () => {
 | 
						|
    const event = { target: document.createElement('input') };
 | 
						|
    const result = isActiveElementTypeable(event);
 | 
						|
    expect(result).toBe(true);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should return true if the active element is a textarea element', () => {
 | 
						|
    const event = { target: document.createElement('textarea') };
 | 
						|
    const result = isActiveElementTypeable(event);
 | 
						|
    expect(result).toBe(true);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should return true if the active element is a contentEditable element', () => {
 | 
						|
    const element = document.createElement('div');
 | 
						|
    element.contentEditable = 'true';
 | 
						|
    const event = { target: element };
 | 
						|
    const result = isActiveElementTypeable(event);
 | 
						|
    expect(result).toBe(true);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should return false if the active element is not typeable', () => {
 | 
						|
    const event = { target: document.createElement('div') };
 | 
						|
    const result = isActiveElementTypeable(event);
 | 
						|
    expect(result).toBe(false);
 | 
						|
  });
 | 
						|
 | 
						|
  it('should return false if the active element is null', () => {
 | 
						|
    const event = { target: null };
 | 
						|
    const result = isActiveElementTypeable(event);
 | 
						|
    expect(result).toBe(false);
 | 
						|
  });
 | 
						|
});
 |