From 61f0c8aa6628efe91cb4ebc7e03ec17a0d4eb03d Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 4 Jan 2020 15:56:00 -0800 Subject: Allow application/xhtml+xml links as comments URL in Atom replies --- reader/atom/atom_10_test.go | 85 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) (limited to 'reader/atom/atom_10_test.go') diff --git a/reader/atom/atom_10_test.go b/reader/atom/atom_10_test.go index d614691..3129e29 100644 --- a/reader/atom/atom_10_test.go +++ b/reader/atom/atom_10_test.go @@ -734,7 +734,7 @@ A website: http://example.org/ } } -func TestParseRepliesLinkRelation(t *testing.T) { +func TestParseRepliesLinkRelationWithHTMLType(t *testing.T) { data := ` @@ -778,6 +778,89 @@ func TestParseRepliesLinkRelation(t *testing.T) { } } +func TestParseRepliesLinkRelationWithXHTMLType(t *testing.T) { + data := ` + + http://www.example.org/myfeed + My Example Feed + 2005-07-28T12:00:00Z + + James + + tag:entries.com,2005:1 + My original entry + 2006-03-01T12:12:12Z + + + + This is my original entry + + ` + + feed, err := Parse(bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if len(feed.Entries) != 1 { + t.Errorf("Incorrect number of entries, got: %d", len(feed.Entries)) + } + + if feed.Entries[0].URL != "http://www.example.org/entries/1" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[0].URL) + } + + if feed.Entries[0].CommentsURL != "http://www.example.org/comments.xhtml" { + t.Errorf("Incorrect entry comments URL, got: %s", feed.Entries[0].CommentsURL) + } +} + +func TestParseRepliesLinkRelationWithNoType(t *testing.T) { + data := ` + + http://www.example.org/myfeed + My Example Feed + 2005-07-28T12:00:00Z + + James + + tag:entries.com,2005:1 + My original entry + 2006-03-01T12:12:12Z + + + This is my original entry + + ` + + feed, err := Parse(bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if len(feed.Entries) != 1 { + t.Errorf("Incorrect number of entries, got: %d", len(feed.Entries)) + } + + if feed.Entries[0].URL != "http://www.example.org/entries/1" { + t.Errorf("Incorrect entry URL, got: %s", feed.Entries[0].URL) + } + + if feed.Entries[0].CommentsURL != "" { + t.Errorf("Incorrect entry comments URL, got: %s", feed.Entries[0].CommentsURL) + } +} + func TestAbsoluteCommentsURL(t *testing.T) { data := `