mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
37 lines
715 B
Go
37 lines
715 B
Go
package navtree
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNavTreeRoot(t *testing.T) {
|
|
t.Run("Sorting by index", func(t *testing.T) {
|
|
treeRoot := NavTreeRoot{
|
|
Children: []*NavLink{
|
|
{Id: "1"},
|
|
{Id: "2"},
|
|
{Id: "3"},
|
|
},
|
|
}
|
|
treeRoot.Sort()
|
|
require.Equal(t, "1", treeRoot.Children[0].Id)
|
|
require.Equal(t, "3", treeRoot.Children[2].Id)
|
|
})
|
|
|
|
t.Run("Sorting by index and SortWeight", func(t *testing.T) {
|
|
treeRoot := NavTreeRoot{
|
|
Children: []*NavLink{
|
|
{Id: "1"},
|
|
{Id: "2"},
|
|
{Id: "3"},
|
|
{Id: "4", SortWeight: 1},
|
|
},
|
|
}
|
|
treeRoot.Sort()
|
|
require.Equal(t, "1", treeRoot.Children[0].Id)
|
|
require.Equal(t, "4", treeRoot.Children[1].Id)
|
|
})
|
|
}
|