Adjust editor tests to use input APIs instead of key events
This commit is contained in:
parent
0185b4fef4
commit
372c3eed52
2 changed files with 14 additions and 6 deletions
|
@ -9708,7 +9708,7 @@ mod tests {
|
||||||
one|
|
one|
|
||||||
two
|
two
|
||||||
three"});
|
three"});
|
||||||
cx.simulate_keystroke(".");
|
cx.simulate_input(".");
|
||||||
handle_completion_request(
|
handle_completion_request(
|
||||||
&mut cx,
|
&mut cx,
|
||||||
indoc! {"
|
indoc! {"
|
||||||
|
@ -9754,9 +9754,9 @@ mod tests {
|
||||||
two|
|
two|
|
||||||
three|
|
three|
|
||||||
additional edit"});
|
additional edit"});
|
||||||
cx.simulate_keystroke(" ");
|
cx.simulate_input(" ");
|
||||||
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
||||||
cx.simulate_keystroke("s");
|
cx.simulate_input("s");
|
||||||
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
||||||
|
|
||||||
cx.assert_editor_state(indoc! {"
|
cx.assert_editor_state(indoc! {"
|
||||||
|
@ -9777,7 +9777,7 @@ mod tests {
|
||||||
cx.condition(|editor, _| editor.context_menu_visible())
|
cx.condition(|editor, _| editor.context_menu_visible())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
cx.simulate_keystroke("i");
|
cx.simulate_input("i");
|
||||||
|
|
||||||
handle_completion_request(
|
handle_completion_request(
|
||||||
&mut cx,
|
&mut cx,
|
||||||
|
@ -9812,9 +9812,11 @@ mod tests {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
cx.set_state("editor|");
|
cx.set_state("editor|");
|
||||||
cx.simulate_keystroke(".");
|
cx.simulate_input(".");
|
||||||
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
||||||
cx.simulate_keystrokes(["c", "l", "o"]);
|
cx.simulate_input("c");
|
||||||
|
cx.simulate_input("l");
|
||||||
|
cx.simulate_input("o");
|
||||||
cx.assert_editor_state("editor.clo|");
|
cx.assert_editor_state("editor.clo|");
|
||||||
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
assert!(cx.editor(|e, _| e.context_menu.is_none()));
|
||||||
cx.update_editor(|editor, cx| {
|
cx.update_editor(|editor, cx| {
|
||||||
|
|
|
@ -139,6 +139,12 @@ impl<'a> EditorTestContext<'a> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn simulate_input(&mut self, input: &str) {
|
||||||
|
self.editor.update(self.cx, |editor, cx| {
|
||||||
|
editor.handle_input(input, cx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pub fn simulate_keystroke(&mut self, keystroke_text: &str) {
|
pub fn simulate_keystroke(&mut self, keystroke_text: &str) {
|
||||||
let keystroke = Keystroke::parse(keystroke_text).unwrap();
|
let keystroke = Keystroke::parse(keystroke_text).unwrap();
|
||||||
self.cx.dispatch_keystroke(self.window_id, keystroke, false);
|
self.cx.dispatch_keystroke(self.window_id, keystroke, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue