diff options
| author | Illia <[email protected]> | 2016-12-07 20:09:04 +0200 |
|---|---|---|
| committer | zeyla <[email protected]> | 2016-12-07 10:09:04 -0800 |
| commit | 626ffb25af35f5b91a76fdccf6788382a1c39455 (patch) | |
| tree | da45ae770e06e68ea12910367a46b2d11aa90987 /tests | |
| parent | Improve Mentions, fix MessageBuilder (diff) | |
| download | serenity-626ffb25af35f5b91a76fdccf6788382a1c39455.tar.xz serenity-626ffb25af35f5b91a76fdccf6788382a1c39455.zip | |
Allow mentionable structs to be used as command arguments
Add EmojiIdentifier, allow User, UserId, Role, RoleId, EmojiIdentifier,
Channel and ChannelId to be used as arguments for commands and add more
parsing functions to utils
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_parsers.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_parsers.rs b/tests/test_parsers.rs new file mode 100644 index 0000000..479ac93 --- /dev/null +++ b/tests/test_parsers.rs @@ -0,0 +1,33 @@ +extern crate serenity; + +use serenity::utils::*; + +#[test] +fn invite_parser() { + assert_eq!(parse_invite("https://discord.gg/abc"), "abc"); + assert_eq!(parse_invite("http://discord.gg/abc"), "abc"); + assert_eq!(parse_invite("discord.gg/abc"), "abc"); +} + +#[test] +fn username_parser() { + assert_eq!(parse_username("<@12345>").unwrap(), 12345); + assert_eq!(parse_username("<@!12345>").unwrap(), 12345); +} + +#[test] +fn role_parser() { + assert_eq!(parse_role("<@&12345>").unwrap(), 12345); +} + +#[test] +fn channel_parser() { + assert_eq!(parse_channel("<#12345>").unwrap(), 12345); +} + +#[test] +fn emoji_parser() { + let emoji = parse_emoji("<:name:12345>").unwrap(); + assert_eq!(emoji.name, "name"); + assert_eq!(emoji.id, 12345); +} |