2017-07-07 01:31:36 +02:00
|
|
|
package pages
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2017-07-20 17:33:25 +02:00
|
|
|
"time"
|
2017-07-07 01:31:36 +02:00
|
|
|
|
|
|
|
"github.com/osteele/gojekyll/config"
|
2017-07-09 01:57:41 +02:00
|
|
|
"github.com/osteele/liquid"
|
2017-07-07 01:31:36 +02:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2017-07-20 17:33:25 +02:00
|
|
|
func TestStaticFile_ToLiquid(t *testing.T) {
|
|
|
|
site := siteFake{t, config.Default()}
|
|
|
|
page, err := NewFile(site, "testdata/static.html", "static.html", map[string]interface{}{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
drop := page.(liquid.Drop).ToLiquid().(map[string]interface{})
|
|
|
|
|
|
|
|
require.Equal(t, "static", drop["basename"])
|
|
|
|
require.Equal(t, "static.html", drop["name"])
|
|
|
|
require.Equal(t, "/static.html", drop["path"])
|
|
|
|
require.Equal(t, ".html", drop["extname"])
|
|
|
|
require.IsType(t, time.Now(), drop["modified_time"])
|
|
|
|
}
|
|
|
|
|
2017-07-07 01:31:36 +02:00
|
|
|
func TestPage_ToLiquid(t *testing.T) {
|
2017-07-20 17:33:25 +02:00
|
|
|
site := siteFake{t, config.Default()}
|
|
|
|
page, err := NewFile(site, "testdata/excerpt.md", "excerpt.md", map[string]interface{}{})
|
2017-07-07 01:31:36 +02:00
|
|
|
require.NoError(t, err)
|
2017-07-09 01:57:41 +02:00
|
|
|
drop := page.(liquid.Drop).ToLiquid()
|
2017-07-07 01:31:36 +02:00
|
|
|
excerpt := drop.(map[string]interface{})["excerpt"]
|
2017-07-23 18:11:23 +02:00
|
|
|
ex, ok := excerpt.([]byte)
|
|
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, "First line.", string(ex))
|
2017-07-07 01:31:36 +02:00
|
|
|
}
|