mirror of
https://github.com/PuerkitoBio/goquery
synced 2025-09-27 05:06:16 +08:00
implement tests for selection methods with invalid selector strings
This commit is contained in:
@@ -14,6 +14,11 @@ func TestFilterNone(t *testing.T) {
|
||||
assertLength(t, sel.Nodes, 0)
|
||||
}
|
||||
|
||||
func TestFilterInvalid(t *testing.T) {
|
||||
sel := Doc().Find(".span12").Filter("")
|
||||
assertLength(t, sel.Nodes, 0)
|
||||
}
|
||||
|
||||
func TestFilterRollback(t *testing.T) {
|
||||
sel := Doc().Find(".pvk-content")
|
||||
sel2 := sel.Filter(".alert").End()
|
||||
@@ -74,6 +79,11 @@ func TestNot(t *testing.T) {
|
||||
assertLength(t, sel.Nodes, 1)
|
||||
}
|
||||
|
||||
func TestNotInvalid(t *testing.T) {
|
||||
sel := Doc().Find(".span12").Not("")
|
||||
assertLength(t, sel.Nodes, 2)
|
||||
}
|
||||
|
||||
func TestNotRollback(t *testing.T) {
|
||||
sel := Doc().Find(".span12")
|
||||
sel2 := sel.Not(".alert").End()
|
||||
@@ -145,6 +155,11 @@ func TestHas(t *testing.T) {
|
||||
// Has() returns the high-level .container-fluid div, and the one that is the immediate parent of center-content
|
||||
}
|
||||
|
||||
func TestHasInvalid(t *testing.T) {
|
||||
sel := Doc().Find(".container-fluid").Has("")
|
||||
assertLength(t, sel.Nodes, 0)
|
||||
}
|
||||
|
||||
func TestHasRollback(t *testing.T) {
|
||||
sel := Doc().Find(".container-fluid")
|
||||
sel2 := sel.Has(".center-content").End()
|
||||
|
Reference in New Issue
Block a user