mirror of
https://github.com/PuerkitoBio/goquery.git
synced 2024-04-21 12:31:36 +00:00
22 lines
426 B
Go
22 lines
426 B
Go
package goquery
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestEach(t *testing.T) {
|
|
var cnt int
|
|
|
|
sel := doc.Find(".hero-unit .row-fluid").Each(func(i int, n *Selection) {
|
|
cnt++
|
|
t.Logf("At index %v, node %v", i, n.Nodes[0].Data)
|
|
}).Find("a")
|
|
|
|
if cnt != 4 {
|
|
t.Errorf("Expected Each() to call function 4 times, got %v times.", cnt)
|
|
}
|
|
if len(sel.Nodes) != 6 {
|
|
t.Errorf("Expected 6 matching nodes, found %v.", len(sel.Nodes))
|
|
}
|
|
}
|