mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Add Page tests for simple methods
This commit is contained in:
@@ -1039,6 +1039,24 @@ func TestPublishedFrontMatter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user