Skip to content

Commit f27f4f6

Browse files
committed
update tests
1 parent 9396512 commit f27f4f6

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

strip_test.go

+20-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ import (
44
"testing"
55
)
66

7-
var stripTests = []struct {
8-
v string
9-
want string
10-
}{
11-
{"<h1>Hello World</h1>", "Hello World"}}
12-
137
func TestStripTags(t *testing.T) {
14-
for _, tt := range stripTests {
15-
got := StripTags(tt.v)
16-
if got != tt.want {
17-
t.Errorf("StripTags(%v): want %v, got %v", tt.v, tt.want, got)
8+
tests := []struct {
9+
input, want string
10+
}{
11+
{"", ""},
12+
{"Hello, World!", "Hello, World!"},
13+
{"foo&amp;bar", "foo&amp;bar"},
14+
{`Hello <a href="www.example.com/">World</a>!`, "Hello World!"},
15+
{"Foo <textarea>Bar</textarea> Baz", "Foo Bar Baz"},
16+
{"Foo <!-- Bar --> Baz", "Foo Baz"},
17+
{"<", "<"},
18+
{"foo < bar", "foo < bar"},
19+
{`Foo<script type="text/javascript">alert(1337)</script>Bar`, "FooBar"},
20+
{`Foo<div title="1>2">Bar`, "FooBar"},
21+
{`I <3 Ponies!`, `I <3 Ponies!`},
22+
{`<script>foo()</script>`, ``},
23+
}
24+
25+
for _, test := range tests {
26+
if got := StripTags(test.input); got != test.want {
27+
t.Errorf("%q: want %q, got %q", test.input, test.want, got)
1828
}
1929
}
2030
}

0 commit comments

Comments
 (0)