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

46 lines
774 B
Go

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)
}
}
}