-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathselect.rs
More file actions
30 lines (25 loc) · 783 Bytes
/
select.rs
File metadata and controls
30 lines (25 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use dialoguer::{theme::ColorfulTheme, Select};
use enigo::{Enigo, Key, KeyboardControllable};
use std::thread;
use std::time::Duration;
#[test]
fn basic_navigation_produces_correct_selection() {
let selections = &[
"Ice Cream",
"Vanilla Cupcake",
"Chocolate Muffin",
"A Pile of sweet, sweet mustard",
];
let mut enigo = Enigo::new();
enigo.key_click(Key::Layout('j'));
enigo.key_down(Key::Return);
thread::sleep(Duration::from_millis(10));
enigo.key_up(Key::Return);
let selection = Select::with_theme(&ColorfulTheme::default())
.with_prompt("Optionally pick your flavor")
.default(0)
.items(&selections[..])
.interact_opt()
.unwrap();
assert_eq!(Some(1), selection);
}