From cea7d3f5a2647f0c0c02d5c22d295ef904852866 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Tue, 28 Jun 2022 13:45:34 -0700 Subject: [PATCH] add test for filter --- crates/command_palette/src/command_palette.rs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index ec4468b463..467a45b93e 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -384,5 +384,34 @@ mod tests { editor.read_with(cx, |editor, cx| { assert_eq!(editor.text(cx), "ab"); }); + + // Add namespace filter, and redeploy the palette + cx.update(|cx| { + cx.update_default_global::(|filter, _| { + filter.filtered_namespaces.insert("editor"); + }) + }); + + workspace.update(cx, |workspace, cx| { + CommandPalette::toggle(workspace, &Toggle, cx); + }); + + // Assert editor command not present + let palette = workspace.read_with(cx, |workspace, _| { + workspace + .modal() + .unwrap() + .clone() + .downcast::() + .unwrap() + }); + + palette + .update(cx, |palette, cx| { + palette.update_matches("bcksp".to_string(), cx) + }) + .await; + + palette.update(cx, |palette, _| assert!(palette.matches.is_empty())); } }