-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands_test.go
77 lines (72 loc) · 1.76 KB
/
commands_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"reflect"
"testing"
"github.com/bwmarrin/discordgo"
)
func Test_getFocusedOption(t *testing.T) {
type args struct {
data discordgo.ApplicationCommandInteractionData
}
expressionOption := discordgo.ApplicationCommandInteractionDataOption{
Name: "expression",
Focused: true,
}
nameOption := discordgo.ApplicationCommandInteractionDataOption{
Name: "name",
Focused: true,
}
tests := []struct {
name string
args args
wantOption *discordgo.ApplicationCommandInteractionDataOption
wantPath string
}{
{
name: "roll expression",
args: args{
discordgo.ApplicationCommandInteractionData{
Name: "roll",
Options: []*discordgo.ApplicationCommandInteractionDataOption{
&expressionOption,
},
},
},
wantOption: &expressionOption,
wantPath: "roll:expression",
},
{
name: "expressions save name",
args: args{
discordgo.ApplicationCommandInteractionData{
Name: "expressions",
Options: []*discordgo.ApplicationCommandInteractionDataOption{
{
Name: "save",
Type: discordgo.ApplicationCommandOptionSubCommand,
Options: []*discordgo.ApplicationCommandInteractionDataOption{
{
Name: "expression",
},
&nameOption,
},
},
},
},
},
wantOption: &nameOption,
wantPath: "expressions save:name",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotOption, gotPath := getFocusedOption(tt.args.data)
if !reflect.DeepEqual(gotOption, tt.wantOption) {
t.Errorf("getFocusedOption() gotOption = %v, want %v", gotOption, tt.wantOption)
}
if gotPath != tt.wantPath {
t.Errorf("getFocusedOption() gotPath = %v, want %v", gotPath, tt.wantPath)
}
})
}
}