2024-02-26 16:16:06 +01:00
|
|
|
|
package markup
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"io"
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestSmartify(t *testing.T) {
|
|
|
|
|
input := `<html>
|
|
|
|
|
<head>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
const url = 'http://localhost:4001/_events/';
|
|
|
|
|
const string = "joe's garage";
|
|
|
|
|
</script>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<p>the album is "Joe's Garage" --by Frank Zappa...</p>
|
|
|
|
|
</body>
|
|
|
|
|
</html>`
|
|
|
|
|
|
|
|
|
|
output, err := Smartify(".html", strings.NewReader(input))
|
2024-02-29 23:34:33 +01:00
|
|
|
|
assertEqual(t, err, nil)
|
2024-02-26 16:16:06 +01:00
|
|
|
|
buf := new(strings.Builder)
|
|
|
|
|
_, err = io.Copy(buf, output)
|
|
|
|
|
assertEqual(t, err, nil)
|
2024-02-29 23:34:33 +01:00
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
|
assertEqual(t, buf.String(), `<html><head>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
const url = 'http://localhost:4001/_events/';
|
|
|
|
|
const string = "joe's garage";
|
|
|
|
|
</script>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<p>the album is “Joe’s Garage” –by Frank Zappa…</p>
|
|
|
|
|
|
|
|
|
|
</body></html>`)
|
|
|
|
|
}
|