Files
kefu_cloud/server/internal/handler/quick_reply_test.go
T
yml2213 c5f28dca1c 新增独立快捷回复模块(团队/个人)
从知识库拆出快捷回复:支持团队暂存与发布同步、个人话术、输入码与工作台 / 调用,以及 CSV 导入导出;管理页顶栏与侧栏对齐。
2026-07-17 21:59:10 +08:00

35 lines
688 B
Go

package handler
import "testing"
func TestNormalizeShortcut(t *testing.T) {
cases := []struct {
in string
want string
wantErr bool
}{
{"", "", false},
{"nh", "nh", false},
{"/NH", "nh", false},
{"hello_1", "hello_1", false},
{"a-b", "a-b", false},
{"中文", "", true},
{"has space", "", true},
}
for _, tc := range cases {
got, err := normalizeShortcut(tc.in)
if tc.wantErr {
if err == nil {
t.Fatalf("normalizeShortcut(%q) 期望错误", tc.in)
}
continue
}
if err != nil {
t.Fatalf("normalizeShortcut(%q): %v", tc.in, err)
}
if got != tc.want {
t.Fatalf("normalizeShortcut(%q)=%q want %q", tc.in, got, tc.want)
}
}
}