summaryrefslogtreecommitdiffstats
path: root/transform/livereloadinject_test.go
blob: 605f65954cc8a93ea737c60dd7250ee6b7552849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()))
	}
}