Files
digital-psychology/apps/api/internal/explore/catalog_test.go
T
jackyu66gitandCursor bd22d9dddd feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-03 11:37:53 +08:00

59 lines
1.2 KiB
Go

package explore
import (
"strings"
"testing"
)
func TestCatalogShape(t *testing.T) {
cats := Catalog()
if len(cats) < 6 {
t.Fatalf("want ≥6 L1 categories, got %d", len(cats))
}
keys := map[string]bool{}
for _, c := range cats {
keys[c.Key] = true
if len(c.Items) < 1 {
t.Fatalf("category %s empty", c.Key)
}
for _, it := range c.Items {
if it.Path == "" || !strings.HasPrefix(it.Path, "/") {
t.Fatalf("bad path %#v", it)
}
}
}
for _, k := range []string{"decode", "star", "relation", "tests", "rhythm", "cards", "growth"} {
if !keys[k] {
t.Fatalf("missing category %s", k)
}
}
// 四核心应排在量表之前
if indexOf(cats, "tests") < indexOf(cats, "star") {
t.Fatal("tests should come after star")
}
}
func indexOf(cats []Category, key string) int {
for i, c := range cats {
if c.Key == key {
return i
}
}
return -1
}
func TestLexiconHardBanOnly(t *testing.T) {
blob := ""
for _, c := range Catalog() {
blob += c.Title + c.Description
for _, it := range c.Items {
blob += it.Title + it.Description
}
}
for _, bad := range []string{"占卜", "算命", "测测"} {
if strings.Contains(blob, bad) {
t.Fatalf("forbidden %q", bad)
}
}
}