This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
srv/utils/html_test.go
Shay Elmualem 45320c8265 Add test cases (#26)
* Add tests for the Exists function

* Add tests for the StripHTMLTags function
2020-10-07 09:13:57 -04:00

27 lines
738 B
Go

package utils
import "testing"
func TestStripHTMLTags(t *testing.T) {
testCases := []struct {
htmlInput string
expect string
}{
{htmlInput: "<html><body<h1>Hello World!</h1></body></html>",
expect: "Hello World!"},
{htmlInput: "<h1>Hello World!</h1>",
expect: "Hello World!"},
{htmlInput: "<h1 style='color: #5e9ca0';>Hello World!</h1>",
expect: "Hello World!"},
{htmlInput: "<td><img style='margin: 1px 15px;' src='images/smiley.png' alt='laughing' width='40' height='16' /><strong>Hello World!</strong></td>", expect: "Hello World!"},
}
for _, tc := range testCases {
got := StripHTMLTags(tc.htmlInput)
expect := tc.expect
if got != expect {
t.Errorf("Expected %s, got %s", expect, got)
}
}
}