49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
|
|
package app
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestQuestionLooksValidAcceptsGenericSearchTerms(t *testing.T) {
|
||
|
|
tests := []string{
|
||
|
|
"全屋定制",
|
||
|
|
"GEO排名优化",
|
||
|
|
"AI搜索排名",
|
||
|
|
}
|
||
|
|
|
||
|
|
for _, text := range tests {
|
||
|
|
if !questionLooksValid(text) {
|
||
|
|
t.Fatalf("questionLooksValid(%q) = false, want true", text)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestBuildCandidateKeepsGenericSearchTermSavable(t *testing.T) {
|
||
|
|
candidate := buildCandidate(
|
||
|
|
"全屋定制",
|
||
|
|
QuestionSourceManual,
|
||
|
|
false,
|
||
|
|
map[string]struct{}{},
|
||
|
|
&questionBrandContext{BrandName: "安徽海翔家居用品销售有限公司"},
|
||
|
|
)
|
||
|
|
|
||
|
|
if candidate.TooShort {
|
||
|
|
t.Fatal("expected generic search term not to be marked too short")
|
||
|
|
}
|
||
|
|
if candidate.SuggestSkip {
|
||
|
|
t.Fatal("expected generic search term not to be suggested for skip")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestQuestionLooksValidRejectsEmptyOrTooShortTerms(t *testing.T) {
|
||
|
|
tests := []string{
|
||
|
|
"",
|
||
|
|
"!?。",
|
||
|
|
"AI",
|
||
|
|
}
|
||
|
|
|
||
|
|
for _, text := range tests {
|
||
|
|
if questionLooksValid(text) {
|
||
|
|
t.Fatalf("questionLooksValid(%q) = true, want false", text)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|