summaryrefslogtreecommitdiffstats
path: root/hugolib/menu_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-08-09 20:06:15 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-06 18:32:19 +0300
commita07293cf9741c9b5c10c80db9870ebfd2d2849c1 (patch)
tree4101356ed2a8e55a1818497e901998aee8f8178e /hugolib/menu_test.go
parentd1212307f257a36c2894d370d7448a1296da4ab3 (diff)
Create a Node map to get proper node translations
In a multi-language setup, before this commit the Node's Translations() method would return some "dummy nodes" that would point to the correct page (Permalink), but would not be the same as the node it points to -- it would not have the translated title etc. The node creation is, however, so mingled with rendering, whihc is too early to have any global state, so the nodes has to be split in a prepare and a render phase. This commits does that with as small a change as possible. This implementation is a temp solution until we fix #2297. Updates #2309
Diffstat (limited to 'hugolib/menu_test.go')
-rw-r--r--hugolib/menu_test.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go
index 4eafba47e..5ca8af8e5 100644
--- a/hugolib/menu_test.go
+++ b/hugolib/menu_test.go
@@ -27,6 +27,7 @@ import (
"github.com/spf13/hugo/source"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
const (
@@ -414,9 +415,13 @@ func doTestSectionPagesMenu(canonifyUrls bool, t *testing.T) {
fishySectionPages := s.Sections["fish-and-chips"]
assert.Equal(t, 1, len(fishySectionPages))
- nodeFirst := s.newSectionListNode("First", "first", firstSectionPages)
- nodeSecond := s.newSectionListNode("Second Section", "second-section", secondSectionPages)
- nodeFishy := s.newSectionListNode("Fish and Chips", "fish-and-chips", fishySectionPages)
+ nodeFirst := s.getNode("sect-first-0")
+ require.NotNil(t, nodeFirst)
+ nodeSecond := s.getNode("sect-second-section-0")
+ require.NotNil(t, nodeSecond)
+ nodeFishy := s.getNode("sect-Fish and Chips-0")
+ require.NotNil(t, nodeFishy)
+
firstSectionMenuEntry := findTestMenuEntryByID(s, "spm", "first")
secondSectionMenuEntry := findTestMenuEntryByID(s, "spm", "second-section")
fishySectionMenuEntry := findTestMenuEntryByID(s, "spm", "Fish and Chips")
@@ -472,7 +477,7 @@ func TestTaxonomyNodeMenu(t *testing.T) {
&MenuEntry{Name: "Somewhere else", URL: "/somewhereelse"}, false, false},
} {
- n, _ := s.newTaxonomyNode(this.taxInfo)
+ n, _ := s.newTaxonomyNode(true, this.taxInfo, i)
isMenuCurrent := n.IsMenuCurrent(this.menu, this.menuItem)
hasMenuCurrent := n.HasMenuCurrent(this.menu, this.menuItem)
@@ -544,7 +549,8 @@ func TestHomeNodeMenu(t *testing.T) {
s := setupMenuTests(t, menuPageSources)
- home := s.newHomeNode()
+ home := s.getNode("home-0")
+
homeMenuEntry := &MenuEntry{Name: home.Title, URL: home.URL()}
for i, this := range []struct {