mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-29 02:53:52 +00:00 
			
		
		
		
	node tests: Avoid __Rewire__ for clipboard API.
This commit is contained in:
		
				
					committed by
					
						 Steve Howell
						Steve Howell
					
				
			
			
				
	
			
			
			
						parent
						
							f54f7cfc33
						
					
				
				
					commit
					7cf62cd6b1
				
			| @@ -43,8 +43,6 @@ const message_edit = zrequire("message_edit"); | ||||
| // Bypass some scary code that runs when we import the module. | ||||
| const popovers = with_field($.fn, "popover", noop, () => zrequire("popovers")); | ||||
|  | ||||
| popovers.__Rewire__("ClipboardJS", noop); | ||||
|  | ||||
| const alice = { | ||||
|     email: "alice@example.com", | ||||
|     full_name: "Alice Smith", | ||||
| @@ -98,6 +96,7 @@ function make_image_stubber() { | ||||
|  | ||||
| function test_ui(label, f) { | ||||
|     run_test(label, (override) => { | ||||
|         override(popovers, "clipboard_enable", noop); | ||||
|         popovers.register_click_handlers(); | ||||
|         f(override); | ||||
|     }); | ||||
|   | ||||
| @@ -54,6 +54,12 @@ let userlist_placement = "right"; | ||||
|  | ||||
| let list_of_popovers = []; | ||||
|  | ||||
| export function clipboard_enable(arg) { | ||||
|     // arg is a selector or element | ||||
|     // We extract this function for testing purpose. | ||||
|     return new ClipboardJS(arg); | ||||
| } | ||||
|  | ||||
| function elem_to_user_id(elem) { | ||||
|     return Number.parseInt(elem.attr("data-user-id"), 10); | ||||
| } | ||||
| @@ -115,7 +121,7 @@ function init_email_clipboard() { | ||||
|             */ | ||||
|             if (copy_email_icon[0]) { | ||||
|                 copy_email_icon.removeClass("hide_copy_icon"); | ||||
|                 const copy_email_clipboard = new ClipboardJS(copy_email_icon[0]); | ||||
|                 const copy_email_clipboard = clipboard_enable(copy_email_icon[0]); | ||||
|                 copy_email_clipboard.on("success", copy_email_handler); | ||||
|             } | ||||
|         } | ||||
| @@ -1251,7 +1257,7 @@ export function register_click_handlers() { | ||||
|         e.preventDefault(); | ||||
|     }); | ||||
|  | ||||
|     new ClipboardJS(".copy_link"); | ||||
|     clipboard_enable(".copy_link"); | ||||
|  | ||||
|     $("body").on("click", ".copy_link", function (e) { | ||||
|         hide_actions_popover(); | ||||
| @@ -1273,7 +1279,7 @@ export function register_click_handlers() { | ||||
|         e.preventDefault(); | ||||
|     }); | ||||
|  | ||||
|     new ClipboardJS(".copy_mention_syntax"); | ||||
|     clipboard_enable(".copy_mention_syntax"); | ||||
|  | ||||
|     $("body").on("click", ".copy_mention_syntax", (e) => { | ||||
|         hide_all(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user