shithub: hugo

Download patch

ref: c462440dcdf3ebe3ca702de30428a430bfec97a6
parent: 66570d2fb3829e6da1d3a0492a3997d219886325
author: Bjørn Erik Pedersen <[email protected]>
date: Sun Feb 7 08:32:08 EST 2016

Add Page tests for simple methods

--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -1039,6 +1039,24 @@
 	}
 }
 
+func TestPageSimpleMethods(t *testing.T) {
+	for i, this := range []struct {
+		assertFunc func(p *Page) bool
+	}{
+		{func(p *Page) bool { return !p.IsNode() }},
+		{func(p *Page) bool { return p.IsPage() }},
+		{func(p *Page) bool { return p.Plain() == "Do Be Do Be Do" }},
+		{func(p *Page) bool { return strings.Join(p.PlainWords(), " ") == "Do Be Do Be Do" }},
+	} {
+
+		p, _ := NewPage("Test")
+		p.Content = "<h1>Do Be Do Be Do</h1>"
+		if !this.assertFunc(p) {
+			t.Errorf("[%d] Page method error", i)
+		}
+	}
+}
+
 func listEqual(left, right []string) bool {
 	if len(left) != len(right) {
 		return false