Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (26 sloc) 625 Bytes
package main
import (
"github.com/PuerkitoBio/goquery"
"strings"
"testing"
)
func TestParseHtml(t *testing.T) {
html := `
<section>
<h1 class="heading">うんこっこ</h1>
<p class="lead">なんかにおうってばよ</p>
</section>
`
r := strings.NewReader(html)
doc, _ := goquery.NewDocumentFromReader(r)
docHeading := doc.Find(".heading").Text()
heading := "うんこっこ"
if docHeading != heading {
t.Errorf("got %v want %v", docHeading, heading)
}
docLead := doc.Find(".lead").Text()
lead := "なんかにおうってばよ"
if docLead != lead {
t.Errorf("got %v want %v", docLead, lead)
}
}