mirror of
https://github.com/PuerkitoBio/goquery.git
synced 2024-04-21 12:31:36 +00:00
add test for issue #26, cannot reproduce
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package goquery
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -673,3 +674,24 @@ func TestClosestNodesRollback(t *testing.T) {
|
||||
sel2 := sel.ClosestNodes(Doc().Find(".pvk-content").Nodes...).End()
|
||||
AssertEqual(t, sel, sel2)
|
||||
}
|
||||
|
||||
func TestIssue26(t *testing.T) {
|
||||
img1 := `<img src="assets/images/gallery/thumb-1.jpg" alt="150x150" />`
|
||||
img2 := `<img alt="150x150" src="assets/images/gallery/thumb-1.jpg" />`
|
||||
cases := []struct {
|
||||
s string
|
||||
l int
|
||||
}{
|
||||
{s: img1 + img2, l: 2},
|
||||
{s: img1, l: 1},
|
||||
{s: img2, l: 1},
|
||||
}
|
||||
for _, c := range cases {
|
||||
doc, err := NewDocumentFromReader(strings.NewReader(c.s))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
sel := doc.Find("img[src]")
|
||||
AssertLength(t, sel.Nodes, c.l)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user