@@ -22,6 +22,29 @@ func TestLabel_CalOpenIssues(t *testing.T) {
2222 assert .EqualValues (t , 2 , label .NumOpenIssues )
2323}
2424
25+ func TestLabel_LoadSelectedLabelsAfterClick (t * testing.T ) {
26+ assert .NoError (t , unittest .PrepareTestDatabase ())
27+ // Loading the label id:8 wich have a scope and an exclusivity
28+ label := unittest .AssertExistsAndLoadBean (t , & issues_model.Label {ID : 8 })
29+
30+ // First test : with negative and scope
31+ label .LoadSelectedLabelsAfterClick ([]int64 {1 , - 8 }, []string {"" , "scope" })
32+ assert .Equal (t , "1" , label .QueryString )
33+ assert .Equal (t , true , label .IsSelected )
34+
35+ // Second test : with duplicates
36+ label .LoadSelectedLabelsAfterClick ([]int64 {1 , 7 , 1 , 7 , 7 }, []string {"" , "scope" , "" , "scope" , "scope" })
37+ // As of now, LoadSelectedLabelsAfterClick() use a map to deduplicate, which
38+ // doesn't garanty the order
39+ assert .Equal (t , true , "1,8" == label .QueryString || "8,1" == label .QueryString , "unexpected value '%s' (expected '1,8' or '8,1')" , label .QueryString )
40+ assert .Equal (t , false , label .IsSelected )
41+
42+ // Third test : empty set
43+ label .LoadSelectedLabelsAfterClick ([]int64 {}, []string {})
44+ assert .False (t , label .IsSelected )
45+ assert .Equal (t , "8" , label .QueryString )
46+ }
47+
2548func TestLabel_ExclusiveScope (t * testing.T ) {
2649 assert .NoError (t , unittest .PrepareTestDatabase ())
2750 label := unittest .AssertExistsAndLoadBean (t , & issues_model.Label {ID : 7 })
0 commit comments