flamingo.me/flamingo-commerce/v3@v3.11.0/category/domain/tree_test.go (about) 1 package domain 2 3 import ( 4 "testing" 5 ) 6 7 func TestTreeData_GetSubTree(t *testing.T) { 8 type args struct { 9 tree Tree 10 } 11 12 var ( 13 inactiveCategory = TreeData{IsActive: false} 14 activeCategory = TreeData{IsActive: true} 15 ) 16 tests := []struct { 17 name string 18 args args 19 want int 20 }{ 21 22 { 23 name: "one subtree", 24 args: args{ 25 tree: TreeData{ 26 SubTreesData: []*TreeData{ 27 &inactiveCategory, 28 }, 29 IsActive: false, 30 }, 31 }, 32 want: 1, 33 }, 34 { 35 name: "two subtree", 36 args: args{ 37 tree: TreeData{ 38 SubTreesData: []*TreeData{ 39 &inactiveCategory, 40 &activeCategory, 41 }, 42 IsActive: false, 43 }, 44 }, 45 want: 2, 46 }, 47 } 48 for _, tt := range tests { 49 t.Run(tt.name, func(t *testing.T) { 50 if got := len(tt.args.tree.SubTrees()); got != tt.want { 51 t.Errorf("SubTrees() = %v, want %v", got, tt.want) 52 } 53 }) 54 } 55 }