package transform
import (
"bytes"
"strings"
"testing"
)
const H5_JS_CONTENT_DOUBLE_QUOTE = "
content foobar. Follow up"
const H5_JS_CONTENT_SINGLE_QUOTE = "content foobar. Follow up"
const H5_JS_CONTENT_ABS_URL = "content foobar. Follow up"
// URL doesn't recognize authorities. BUG?
//const H5_JS_CONTENT_ABS_URL = "content foobar. Follow up"
const CORRECT_OUTPUT_SRC_HREF = "content foobar. Follow up"
func TestAbsUrlify(t *testing.T) {
tests := []struct {
content string
expected string
}{
{H5_JS_CONTENT_DOUBLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
{H5_JS_CONTENT_SINGLE_QUOTE, CORRECT_OUTPUT_SRC_HREF},
{H5_JS_CONTENT_ABS_URL, H5_JS_CONTENT_ABS_URL},
}
for _, test := range tests {
tr := &Transformer{
BaseURL: "http://base",
}
out := new(bytes.Buffer)
err := tr.Apply(strings.NewReader(test.content), out)
if err != nil {
t.Errorf("Unexpected error: %s", err)
}
if test.expected != string(out.Bytes()) {
t.Errorf("Expected:\n%s\nGot:\n%s", test.expected, string(out.Bytes()))
}
}
}