use crate::channels::commands::strip_command_handle;
#[test]
fn handle_with_argument_preserves_argument() {
assert_eq!(
strip_command_handle("/respond_to@yourbot mention"),
"/respond_to mention"
);
}
#[test]
fn handle_with_path_argument() {
assert_eq!(strip_command_handle("/cd@yourbot /tmp"), "/cd /tmp");
}
#[test]
fn bare_command_with_handle() {
assert_eq!(strip_command_handle("/help@yourbot"), "/help");
}
#[test]
fn command_without_handle_unchanged() {
assert_eq!(
strip_command_handle("/respond_to mention"),
"/respond_to mention"
);
}
#[test]
fn at_sign_in_argument_untouched() {
assert_eq!(
strip_command_handle("/sessions user@example.com"),
"/sessions user@example.com"
);
}
#[test]
fn handle_on_token_and_at_in_argument() {
assert_eq!(
strip_command_handle("/sessions@yourbot user@example.com"),
"/sessions user@example.com"
);
}
#[test]
fn non_command_text_untouched() {
assert_eq!(strip_command_handle("hello @you"), "hello @you");
assert_eq!(strip_command_handle("mail me at a@b.c"), "mail me at a@b.c");
}
#[test]
fn plain_command_unchanged() {
assert_eq!(strip_command_handle("/help"), "/help");
}
#[test]
fn surrounding_whitespace_trimmed() {
assert_eq!(strip_command_handle(" /help@yourbot "), "/help");
assert_eq!(strip_command_handle(" plain text "), "plain text");
}
#[test]
fn multiline_argument_preserved() {
assert_eq!(
strip_command_handle("/cmd@yourbot line1\nline2"),
"/cmd line1\nline2"
);
}