mirror of
https://github.com/PuerkitoBio/goquery
synced 2025-10-29 19:02:25 +08:00
22 lines
428 B
Go
22 lines
428 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))
|
|
}
|
|
}
|