33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package fa
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/PuerkitoBio/goquery"
|
|
)
|
|
|
|
// A cursor page (/msg/submissions/new~{id}@72/) may render its gallery
|
|
// without the #messagecenter-submissions wrapper the default view uses.
|
|
// parseSubmissionInboxPage must still recover the submissions instead of
|
|
// silently returning an empty page, which would truncate the crawl.
|
|
func TestParseSubmissionInboxPage_FindsFiguresOutsideMessageCenter(t *testing.T) {
|
|
html := `<html><body>
|
|
<section class="gallery">
|
|
<figure id="sid-501"><a href="/view/501/" title="A"><img src="/a.png"/></a></figure>
|
|
<figure id="sid-500"><a href="/view/500/" title="B"><img src="/b.png"/></a></figure>
|
|
</section>
|
|
</body></html>`
|
|
doc, err := goquery.NewDocumentFromReader(strings.NewReader(html))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
items, _ := parseSubmissionInboxPage(doc, false)
|
|
if len(items) != 2 {
|
|
t.Fatalf("got %d items; want 2", len(items))
|
|
}
|
|
if items[0].ID != 501 || items[1].ID != 500 {
|
|
t.Errorf("ids = %d, %d; want 501, 500", items[0].ID, items[1].ID)
|
|
}
|
|
}
|