1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-18 12:52:45 +00:00
arikawa/bot/extras/arguments/mention_test.go

46 lines
774 B
Go
Raw Normal View History

2020-02-04 16:13:11 +00:00
package arguments
import (
"testing"
"github.com/diamondburned/arikawa/discord"
)
func TestMention(t *testing.T) {
var (
c ChannelMention
u UserMention
r RoleMention
)
type mention interface {
Parse(arg string) error
ID() discord.Snowflake
Mention() string
}
var tests = []struct {
mention
str string
id discord.Snowflake
}{
{&c, "<#123123>", 123123},
{&r, "<@&23321>", 23321},
{&u, "<@123123>", 123123},
}
for _, test := range tests {
if err := test.Parse(test.str); err != nil {
t.Fatal("Expected", test.id, "error:", err)
}
if id := test.ID(); id != test.id {
t.Fatal("Expected", test.id, "got", id)
}
if mention := test.Mention(); mention != test.str {
t.Fatal("Expected", test.str, "got", mention)
}
}
}