Add missing menu tests

This commit is contained in:
Bjørn Erik Pedersen 2016-02-07 13:43:42 +01:00
parent c462440dcd
commit 0f6c8439b9

View file

@ -566,6 +566,20 @@ func TestHomeNodeMenu(t *testing.T) {
}
}
func TestHopefullyUniqueID(t *testing.T) {
assert.Equal(t, "i", (&MenuEntry{Identifier: "i", URL: "u", Name: "n"}).hopefullyUniqueID())
assert.Equal(t, "u", (&MenuEntry{Identifier: "", URL: "u", Name: "n"}).hopefullyUniqueID())
assert.Equal(t, "n", (&MenuEntry{Identifier: "", URL: "", Name: "n"}).hopefullyUniqueID())
}
func TestAddMenuEntryChild(t *testing.T) {
root := &MenuEntry{Weight: 1}
root.AddChild(&MenuEntry{Weight: 2})
root.AddChild(&MenuEntry{Weight: 1})
assert.Equal(t, 2, len(root.Children))
assert.Equal(t, 1, root.Children[0].Weight)
}
var testMenuIdentityMatcher = func(me *MenuEntry, id string) bool { return me.Identifier == id }
var testMenuNameMatcher = func(me *MenuEntry, id string) bool { return me.Name == id }