mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/new-for-builtins.md https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/throw-new-error.md https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/error-message.md Signed-off-by: Anders Kaseorg <anders@zulip.com>
		
			
				
	
	
		
			42 lines
		
	
	
		
			736 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			736 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| 
 | |
| set_global("$", global.make_zjquery());
 | |
| 
 | |
| zrequire("keydown_util");
 | |
| 
 | |
| run_test("test_early_returns", () => {
 | |
|     const stub = $.create("stub");
 | |
|     const opts = {
 | |
|         elem: stub,
 | |
|         handlers: {
 | |
|             left_arrow: () => {
 | |
|                 throw new Error("do not dispatch this with alt key");
 | |
|             },
 | |
|         },
 | |
|     };
 | |
| 
 | |
|     keydown_util.handle(opts);
 | |
| 
 | |
|     const e1 = {
 | |
|         type: "keydown",
 | |
|         which: 17, // not in keys
 | |
|     };
 | |
| 
 | |
|     stub.trigger(e1);
 | |
| 
 | |
|     const e2 = {
 | |
|         type: "keydown",
 | |
|         which: 13, // no handler
 | |
|     };
 | |
| 
 | |
|     stub.trigger(e2);
 | |
| 
 | |
|     const e3 = {
 | |
|         type: "keydown",
 | |
|         which: 37,
 | |
|         altKey: true, // let browser handle
 | |
|     };
 | |
| 
 | |
|     stub.trigger(e3);
 | |
| });
 |