mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
57cd953997
Added the new general module's test file, general_test.go. This replaces the helpers_test.go file. There is also a minor defect fix in general.go's StripHTML function. The correct xhtml tag for a break is <br /> not </br>. I've also removed the unnecessary spaces before the replacement "\n". The new test module also reflects this change. Conflicts: helpers/general.go
22 lines
444 B
Go
22 lines
444 B
Go
package helpers
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestStripHTML(t *testing.T) {
|
|
type test struct {
|
|
input, expected string
|
|
}
|
|
data := []test{
|
|
{"<h1>strip h1 tag <h1>", "strip h1 tag "},
|
|
{"<p> strip p tag </p>", " strip p tag \n"},
|
|
{"</br> strip br<br>", " strip br\n"},
|
|
}
|
|
for i, d := range data {
|
|
output := StripHTML(d.input)
|
|
if d.expected != output {
|
|
t.Errorf("Test %d failed. Expected %q got %q", i, d.expected, output)
|
|
}
|
|
}
|
|
}
|