Permalink
Browse files

add test for issue #26, cannot reproduce

  • Loading branch information...
1 parent aa0519a commit d247f5b79a5211086662dd77e550a4131fbc1b50 @mna mna committed Nov 12, 2013
Showing with 22 additions and 0 deletions.
  1. +22 −0 traversal_test.go
View
@@ -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)
+ }
+}

0 comments on commit d247f5b

Please sign in to comment.