mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-31 16:40:37 +01:00
hide_aliases
tests
This commit is contained in:
parent
ed90485fdf
commit
f3281b6eac
1 changed files with 87 additions and 0 deletions
|
@ -489,6 +489,93 @@ fn aliases_help_message() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "macros")]
|
||||||
|
fn hide_aliases_for_unaliases_command() {
|
||||||
|
#[derive(BotCommands, Debug, PartialEq)]
|
||||||
|
#[command(rename_rule = "snake_case")]
|
||||||
|
enum DefaultCommands {
|
||||||
|
/// Start command.
|
||||||
|
Start,
|
||||||
|
/// Show help message.
|
||||||
|
#[command(hide_aliases)]
|
||||||
|
Help,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/start", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/help", "").unwrap());
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
"/start — Start command.\n/help — Show help message.",
|
||||||
|
DefaultCommands::descriptions().to_string()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "macros")]
|
||||||
|
fn hide_aliases_with_alias() {
|
||||||
|
#[derive(BotCommands, Debug, PartialEq)]
|
||||||
|
#[command(rename_rule = "snake_case")]
|
||||||
|
enum DefaultCommands {
|
||||||
|
/// Start.
|
||||||
|
#[command(alias = "s")]
|
||||||
|
Start,
|
||||||
|
/// Help.
|
||||||
|
#[command(alias = "h", hide_aliases)]
|
||||||
|
Help,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/start", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/help", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/h", "").unwrap());
|
||||||
|
|
||||||
|
assert_eq!("/start, /s — Start.\n/help — Help.", DefaultCommands::descriptions().to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "macros")]
|
||||||
|
fn hide_command_with_aliases() {
|
||||||
|
#[derive(BotCommands, Debug, PartialEq)]
|
||||||
|
#[command(rename_rule = "snake_case")]
|
||||||
|
enum DefaultCommands {
|
||||||
|
/// Start.
|
||||||
|
#[command(alias = "s", hide)]
|
||||||
|
Start,
|
||||||
|
/// Help.
|
||||||
|
#[command(alias = "h")]
|
||||||
|
Help,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/start", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/s", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/help", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/h", "").unwrap());
|
||||||
|
|
||||||
|
assert_eq!("/help, /h — Help.", DefaultCommands::descriptions().to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "macros")]
|
||||||
|
fn hide_aliases_with_aliases() {
|
||||||
|
#[derive(BotCommands, Debug, PartialEq)]
|
||||||
|
#[command(rename_rule = "snake_case")]
|
||||||
|
enum DefaultCommands {
|
||||||
|
#[command(aliases = ["s", "старт"])]
|
||||||
|
Start,
|
||||||
|
#[command(aliases = ["h", "помощь"], hide_aliases)]
|
||||||
|
Help,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/start", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/s", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Start, DefaultCommands::parse("/старт", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/help", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/h", "").unwrap());
|
||||||
|
assert_eq!(DefaultCommands::Help, DefaultCommands::parse("/помощь", "").unwrap());
|
||||||
|
|
||||||
|
assert_eq!("/start, /s, /старт\n/help", DefaultCommands::descriptions().to_string());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "macros")]
|
#[cfg(feature = "macros")]
|
||||||
fn custom_result() {
|
fn custom_result() {
|
||||||
|
|
Loading…
Reference in a new issue