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) } } }