2017-07-03 15:37:14 +02:00
|
|
|
package pages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/osteele/gojekyll/config"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2017-07-07 01:31:36 +02:00
|
|
|
type containerFake struct {
|
|
|
|
cfg config.Config
|
2017-07-03 15:37:14 +02:00
|
|
|
prefix string
|
|
|
|
}
|
|
|
|
|
2017-07-07 01:31:36 +02:00
|
|
|
func (c containerFake) Config() *config.Config { return &c.cfg }
|
|
|
|
func (c containerFake) PathPrefix() string { return c.prefix }
|
|
|
|
func (c containerFake) OutputExt(p string) string { return filepath.Ext(p) }
|
2017-07-03 15:37:14 +02:00
|
|
|
|
|
|
|
func TestPageCategories(t *testing.T) {
|
2017-07-07 01:31:36 +02:00
|
|
|
c := containerFake{config.Default(), ""}
|
2017-07-03 15:37:14 +02:00
|
|
|
fm := map[string]interface{}{"categories": "b a"}
|
|
|
|
f := file{container: c, frontMatter: fm}
|
|
|
|
require.Equal(t, []string{"a", "b"}, f.Categories())
|
|
|
|
}
|