From 4395c31cc57f9d039cc7920ec135d48024bf3b2b Mon Sep 17 00:00:00 2001 From: shannmu Date: Wed, 10 Jul 2024 22:52:24 +0800 Subject: [PATCH] test(clap_complete): Add test case for hiding possible values --- clap_complete/tests/testsuite/dynamic.rs | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/clap_complete/tests/testsuite/dynamic.rs b/clap_complete/tests/testsuite/dynamic.rs index 2863da32034..f11cccbd5f5 100644 --- a/clap_complete/tests/testsuite/dynamic.rs +++ b/clap_complete/tests/testsuite/dynamic.rs @@ -122,6 +122,31 @@ hello-world-foo" ); } +#[test] +fn suggest_hidden_possible_value() { + let mut cmd = Command::new("exhaustive").arg( + clap::Arg::new("possible_value").long("test").value_parser([ + PossibleValue::new("test-visible").help("Say hello to the world"), + PossibleValue::new("test-hidden") + .help("Say hello to the moon") + .hide(true), + ]), + ); + + assert_data_eq!( + complete!(cmd, "--test=test"), + snapbox::str![ + "--test=test-visible\tSay hello to the world +--test=test-hidden\tSay hello to the moon" + ] + ); + + assert_data_eq!( + complete!(cmd, "--test=test-h"), + snapbox::str!["--test=test-hidden\tSay hello to the moon"] + ) +} + #[test] fn suggest_hidden_long_flag_aliases() { let mut cmd = Command::new("exhaustive")