owl-blogs/webmention_test.go

37 lines
856 B
Go
Raw Normal View History

2022-08-27 21:01:14 +00:00
package owl_test
import (
"h4kor/owl-blogs"
"testing"
)
//
// https://www.w3.org/TR/webmention/#h-webmention-verification
//
func TestParseValidHEntry(t *testing.T) {
html := []byte("<div class=\"h-entry\"><div class=\"p-name\">Foo</div></div>")
2022-09-04 15:10:40 +00:00
parser := &owl.OwlHtmlParser{}
entry, err := parser.ParseHEntry(html)
2022-08-27 21:01:14 +00:00
if err != nil {
t.Errorf("Unable to parse feed: %v", err)
}
if entry.Title != "Foo" {
t.Errorf("Wrong Title. Expected %v, got %v", "Foo", entry.Title)
}
}
func TestParseValidHEntryWithoutTitle(t *testing.T) {
html := []byte("<div class=\"h-entry\"></div><div class=\"p-name\">Foo</div>")
2022-09-04 15:10:40 +00:00
parser := &owl.OwlHtmlParser{}
entry, err := parser.ParseHEntry(html)
2022-08-27 21:01:14 +00:00
if err != nil {
t.Errorf("Unable to parse feed: %v", err)
}
if entry.Title != "" {
t.Errorf("Wrong Title. Expected %v, got %v", "Foo", entry.Title)
}
}