1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 13:54:42 +01:00
gojekyll/pages/file_test.go
Oliver Steele a48087bd9b Coverage
2017-07-04 17:36:06 -04:00

31 lines
850 B
Go

package pages
import (
"path/filepath"
"testing"
"github.com/osteele/gojekyll/config"
"github.com/stretchr/testify/require"
)
type containerMock struct {
c config.Config
prefix string
}
func (c containerMock) OutputExt(p string) string { return filepath.Ext(p) }
func (c containerMock) PathPrefix() string { return c.prefix }
func TestPageCategories(t *testing.T) {
require.Equal(t, []string{"a", "b"}, sortedStringValue("b a"))
require.Equal(t, []string{"a", "b"}, sortedStringValue([]interface{}{"b", "a"}))
require.Equal(t, []string{"a", "b"}, sortedStringValue([]string{"b", "a"}))
require.Equal(t, []string{}, sortedStringValue(3))
c := containerMock{config.Default(), ""}
fm := map[string]interface{}{"categories": "b a"}
f := file{container: c, frontMatter: fm}
require.Equal(t, []string{"a", "b"}, f.Categories())
}