2020-03-21 20:27:17 +00:00
|
|
|
package bdiscord
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2022-03-12 16:06:39 +00:00
|
|
|
"github.com/bwmarrin/discordgo"
|
2020-03-21 20:27:17 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHandleEmbed(t *testing.T) {
|
|
|
|
testcases := map[string]struct {
|
|
|
|
embed *discordgo.MessageEmbed
|
|
|
|
result string
|
|
|
|
}{
|
|
|
|
"allempty": {
|
|
|
|
embed: &discordgo.MessageEmbed{},
|
|
|
|
result: "",
|
|
|
|
},
|
|
|
|
"one": {
|
|
|
|
embed: &discordgo.MessageEmbed{
|
|
|
|
Title: "blah",
|
|
|
|
},
|
2020-05-06 22:19:48 +00:00
|
|
|
result: " embed: blah\n",
|
2020-03-21 20:27:17 +00:00
|
|
|
},
|
|
|
|
"two": {
|
|
|
|
embed: &discordgo.MessageEmbed{
|
|
|
|
Title: "blah",
|
|
|
|
Description: "blah2",
|
|
|
|
},
|
2020-05-06 22:19:48 +00:00
|
|
|
result: " embed: blah - blah2\n",
|
2020-03-21 20:27:17 +00:00
|
|
|
},
|
|
|
|
"three": {
|
|
|
|
embed: &discordgo.MessageEmbed{
|
|
|
|
Title: "blah",
|
|
|
|
Description: "blah2",
|
|
|
|
URL: "blah3",
|
|
|
|
},
|
2020-05-06 22:19:48 +00:00
|
|
|
result: " embed: blah - blah2 - blah3\n",
|
2020-03-21 20:27:17 +00:00
|
|
|
},
|
|
|
|
"twob": {
|
|
|
|
embed: &discordgo.MessageEmbed{
|
|
|
|
Description: "blah2",
|
|
|
|
URL: "blah3",
|
|
|
|
},
|
2020-05-06 22:19:48 +00:00
|
|
|
result: " embed: blah2 - blah3\n",
|
2020-03-21 20:27:17 +00:00
|
|
|
},
|
|
|
|
"oneb": {
|
|
|
|
embed: &discordgo.MessageEmbed{
|
|
|
|
URL: "blah3",
|
|
|
|
},
|
2020-05-06 22:19:48 +00:00
|
|
|
result: " embed: blah3\n",
|
2020-03-21 20:27:17 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range testcases {
|
|
|
|
assert.Equalf(t, tc.result, handleEmbed(tc.embed), "Testcases %s", name)
|
|
|
|
}
|
|
|
|
}
|