1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-12-02 16:57:51 +01:00
gojekyll/config/config_test.go

48 lines
1.1 KiB
Go
Raw Normal View History

2017-06-22 23:53:46 +02:00
package config
import (
2017-07-03 17:48:06 +02:00
"strings"
2017-06-22 23:53:46 +02:00
"testing"
"github.com/stretchr/testify/require"
)
2017-07-07 20:55:03 +02:00
func TestConfig_SourceDir(t *testing.T) {
2017-07-03 17:48:06 +02:00
c := Default()
require.True(t, strings.HasPrefix(c.SourceDir(), "/"))
}
2017-06-22 23:53:46 +02:00
func TestDefaultConfig(t *testing.T) {
c := Default()
require.Equal(t, ".", c.Source)
require.Equal(t, "./_site", c.Destination)
require.Equal(t, "_layouts", c.LayoutsDir)
}
2017-07-07 20:55:03 +02:00
func TestConfig_Plugins(t *testing.T) {
2017-07-03 17:48:06 +02:00
c := Default()
2017-07-03 19:03:45 +02:00
require.NoError(t, Unmarshal([]byte(`plugins: ['a']`), &c))
2017-07-03 17:48:06 +02:00
require.Equal(t, []string{"a"}, c.Plugins)
c = Default()
2017-07-03 19:03:45 +02:00
require.NoError(t, Unmarshal([]byte(`gems: ['a']`), &c))
2017-07-03 17:48:06 +02:00
require.Equal(t, []string{"a"}, c.Plugins)
}
2017-06-22 23:53:46 +02:00
func TestUnmarshal(t *testing.T) {
c := Default()
2017-07-07 20:55:03 +02:00
require.NoError(t, Unmarshal([]byte(`source: x`), &c))
2017-06-22 23:53:46 +02:00
require.Equal(t, "x", c.Source)
require.Equal(t, "./_site", c.Destination)
2017-07-07 20:55:03 +02:00
c = Default()
require.NoError(t, Unmarshal([]byte(`collections: \n- x\n-y`), &c))
// fmt.Println(c.Collections)
2017-06-22 23:53:46 +02:00
}
2017-06-24 19:30:01 +02:00
2017-07-07 20:55:03 +02:00
func TestConfig_IsMarkdown(t *testing.T) {
2017-06-24 19:30:01 +02:00
c := Default()
require.True(t, c.IsMarkdown("name.md"))
require.True(t, c.IsMarkdown("name.markdown"))
require.False(t, c.IsMarkdown("name.html"))
}