uncomment and augment mouse_context_menu tests

Piotr Osiewicz created

Change summary

crates/editor2/src/mouse_context_menu.rs | 71 +++++++++++++------------
1 file changed, 36 insertions(+), 35 deletions(-)

Detailed changes

crates/editor2/src/mouse_context_menu.rs 🔗

@@ -69,42 +69,43 @@ pub fn deploy_context_menu(
     cx.notify();
 }
 
-// #[cfg(test)]
-// mod tests {
-//     use super::*;
-//     use crate::{editor_tests::init_test, test::editor_lsp_test_context::EditorLspTestContext};
-//     use indoc::indoc;
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::{editor_tests::init_test, test::editor_lsp_test_context::EditorLspTestContext};
+    use indoc::indoc;
 
-//     #[gpui::test]
-//     async fn test_mouse_context_menu(cx: &mut gpui::TestAppContext) {
-//         init_test(cx, |_| {});
+    #[gpui::test]
+    async fn test_mouse_context_menu(cx: &mut gpui::TestAppContext) {
+        init_test(cx, |_| {});
 
-//         let mut cx = EditorLspTestContext::new_rust(
-//             lsp::ServerCapabilities {
-//                 hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
-//                 ..Default::default()
-//             },
-//             cx,
-//         )
-//         .await;
+        let mut cx = EditorLspTestContext::new_rust(
+            lsp::ServerCapabilities {
+                hover_provider: Some(lsp::HoverProviderCapability::Simple(true)),
+                ..Default::default()
+            },
+            cx,
+        )
+        .await;
 
-//         cx.set_state(indoc! {"
-//             fn teˇst() {
-//                 do_work();
-//             }
-//         "});
-//         let point = cx.display_point(indoc! {"
-//             fn test() {
-//                 do_wˇork();
-//             }
-//         "});
-//         cx.update_editor(|editor, cx| deploy_context_menu(editor, Default::default(), point, cx));
+        cx.set_state(indoc! {"
+            fn teˇst() {
+                do_work();
+            }
+        "});
+        let point = cx.display_point(indoc! {"
+            fn test() {
+                do_wˇork();
+            }
+        "});
+        cx.editor(|editor, app| assert!(editor.mouse_context_menu.is_none()));
+        cx.update_editor(|editor, cx| deploy_context_menu(editor, Default::default(), point, cx));
 
-//         cx.assert_editor_state(indoc! {"
-//             fn test() {
-//                 do_wˇork();
-//             }
-//         "});
-//         cx.editor(|editor, app| assert!(editor.mouse_context_menu.read(app).visible()));
-//     }
-// }
+        cx.assert_editor_state(indoc! {"
+            fn test() {
+                do_wˇork();
+            }
+        "});
+        cx.editor(|editor, app| assert!(editor.mouse_context_menu.is_some()));
+    }
+}