hugo/transform/livereloadinject_test.go
Kato Kazuyoshi ef4dfcec6c Load livereload.js from "/"
Fix #1406
Instead of loading the file from http://localhost:port/, it can be
loaded from /.
2015-10-15 16:36:13 -04:00

20 lines
500 B
Go

package transform
import (
"bytes"
"github.com/spf13/hugo/helpers"
"testing"
)
func TestLiveReloadInject(t *testing.T) {
out := new(bytes.Buffer)
in := helpers.StringToReader("</body>")
tr := NewChain(LiveReloadInject)
tr.Apply(out, in, []byte("path"))
expected := `<script data-no-instant>document.write('<script src="/livereload.js?mindelay=10"></' + 'script>')</script></body>`
if string(out.Bytes()) != expected {
t.Errorf("Expected %s got %s", expected, string(out.Bytes()))
}
}