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 TestFirstEmpty(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 0)
|
assertLength(t, sel.Nodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFirstInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("").First()
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestFirstRollback(t *testing.T) {
|
func TestFirstRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content")
|
sel := Doc().Find(".pvk-content")
|
||||||
sel2 := sel.First().End()
|
sel2 := sel.First().End()
|
||||||
@@ -36,6 +41,11 @@ func TestLastEmpty(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 0)
|
assertLength(t, sel.Nodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLastInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("").Last()
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestLastRollback(t *testing.T) {
|
func TestLastRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content")
|
sel := Doc().Find(".pvk-content")
|
||||||
sel2 := sel.Last().End()
|
sel2 := sel.Last().End()
|
||||||
@@ -63,6 +73,11 @@ func TestEqEmpty(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 0)
|
assertLength(t, sel.Nodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestEqInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("").Eq(0)
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestEqInvalidPositive(t *testing.T) {
|
func TestEqInvalidPositive(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content").Eq(3)
|
sel := Doc().Find(".pvk-content").Eq(3)
|
||||||
assertLength(t, sel.Nodes, 0)
|
assertLength(t, sel.Nodes, 0)
|
||||||
@@ -85,6 +100,16 @@ func TestSlice(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 2)
|
assertLength(t, sel.Nodes, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSliceEmpty(t *testing.T) {
|
||||||
|
sel := Doc().Find("x").Slice(0, 2)
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSliceInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("").Slice(0, 2)
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSliceOutOfBounds(t *testing.T) {
|
func TestSliceOutOfBounds(t *testing.T) {
|
||||||
defer assertPanic(t)
|
defer assertPanic(t)
|
||||||
Doc().Find(".pvk-content").Slice(2, 12)
|
Doc().Find(".pvk-content").Slice(2, 12)
|
||||||
@@ -157,6 +182,13 @@ func TestIndexSelector(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIndexSelectorInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".hero-unit")
|
||||||
|
if i := sel.IndexSelector(""); i != -1 {
|
||||||
|
t.Errorf("Expected index of -1, got %v.", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestIndexOfNode(t *testing.T) {
|
func TestIndexOfNode(t *testing.T) {
|
||||||
sel := Doc().Find("div.pvk-gutter")
|
sel := Doc().Find("div.pvk-gutter")
|
||||||
if i := sel.IndexOfNode(sel.Nodes[1]); i != 1 {
|
if i := sel.IndexOfNode(sel.Nodes[1]); i != 1 {
|
||||||
|
@@ -9,6 +9,16 @@ func TestAdd(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 19)
|
assertLength(t, sel.Nodes, 19)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAddInvalid(t *testing.T) {
|
||||||
|
sel1 := Doc().Find("div.row-fluid")
|
||||||
|
sel2 := sel1.Add("")
|
||||||
|
assertLength(t, sel1.Nodes, 19)
|
||||||
|
assertLength(t, sel2.Nodes, 19)
|
||||||
|
if sel1 == sel2 {
|
||||||
|
t.Errorf("selections should not be the same")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAddRollback(t *testing.T) {
|
func TestAddRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content")
|
sel := Doc().Find(".pvk-content")
|
||||||
sel2 := sel.Add("a").End()
|
sel2 := sel.Add("a").End()
|
||||||
|
@@ -12,8 +12,8 @@ func (s *Selection) Filter(selector string) *Selection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FilterMatcher reduces the set of matched elements to those that match
|
// FilterMatcher reduces the set of matched elements to those that match
|
||||||
// the given matcher.
|
// the given matcher. It returns a new Selection object for this subset
|
||||||
// It returns a new Selection object for this subset of matching elements.
|
// of matching elements.
|
||||||
func (s *Selection) FilterMatcher(m Matcher) *Selection {
|
func (s *Selection) FilterMatcher(m Matcher) *Selection {
|
||||||
return pushStack(s, winnow(s, m, true))
|
return pushStack(s, winnow(s, m, true))
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,11 @@ func TestFilterNone(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 0)
|
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) {
|
func TestFilterRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content")
|
sel := Doc().Find(".pvk-content")
|
||||||
sel2 := sel.Filter(".alert").End()
|
sel2 := sel.Filter(".alert").End()
|
||||||
@@ -74,6 +79,11 @@ func TestNot(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 1)
|
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) {
|
func TestNotRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".span12")
|
sel := Doc().Find(".span12")
|
||||||
sel2 := sel.Not(".alert").End()
|
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
|
// 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) {
|
func TestHasRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.Has(".center-content").End()
|
sel2 := sel.Has(".center-content").End()
|
||||||
|
15
i114_test.go
15
i114_test.go
@@ -1,15 +0,0 @@
|
|||||||
package goquery
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestIssue114(t *testing.T) {
|
|
||||||
d, err := NewDocumentFromReader(strings.NewReader("<html><head><title>some title</title></head><body><h1>H1</h1></body></html>"))
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
sel := d.Find("~")
|
|
||||||
t.Log(sel)
|
|
||||||
}
|
|
@@ -11,6 +11,13 @@ func TestIs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIsInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".footer p:nth-child(1)")
|
||||||
|
if sel.Is("") {
|
||||||
|
t.Error("Is should not succeed with invalid selector string")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestIsPositional(t *testing.T) {
|
func TestIsPositional(t *testing.T) {
|
||||||
sel := Doc().Find(".footer p:nth-child(2)")
|
sel := Doc().Find(".footer p:nth-child(2)")
|
||||||
if !sel.Is("p:nth-child(2)") {
|
if !sel.Is("p:nth-child(2)") {
|
||||||
|
@@ -21,9 +21,9 @@ func TestFindNotSelf(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 0)
|
assertLength(t, sel.Nodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindInvalidSelector(t *testing.T) {
|
func TestFindInvalid(t *testing.T) {
|
||||||
defer assertPanic(t)
|
sel := Doc().Find(":+ ^")
|
||||||
Doc().Find(":+ ^")
|
assertLength(t, sel.Nodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestChainedFind(t *testing.T) {
|
func TestChainedFind(t *testing.T) {
|
||||||
@@ -31,6 +31,11 @@ func TestChainedFind(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 4)
|
assertLength(t, sel.Nodes, 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestChainedFindInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("div.hero-unit").Find("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestChildren(t *testing.T) {
|
func TestChildren(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content").Children()
|
sel := Doc().Find(".pvk-content").Children()
|
||||||
assertLength(t, sel.Nodes, 5)
|
assertLength(t, sel.Nodes, 5)
|
||||||
@@ -58,6 +63,11 @@ func TestChildrenFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 1)
|
assertLength(t, sel.Nodes, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestChildrenFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".pvk-content").ChildrenFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestChildrenFilteredRollback(t *testing.T) {
|
func TestChildrenFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content")
|
sel := Doc().Find(".pvk-content")
|
||||||
sel2 := sel.ChildrenFiltered(".hero-unit").End()
|
sel2 := sel.ChildrenFiltered(".hero-unit").End()
|
||||||
@@ -69,6 +79,11 @@ func TestContentsFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 1)
|
assertLength(t, sel.Nodes, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContentsFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".pvk-content").ContentsFiltered("~")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestContentsFilteredRollback(t *testing.T) {
|
func TestContentsFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-content")
|
sel := Doc().Find(".pvk-content")
|
||||||
sel2 := sel.ContentsFiltered(".hero-unit").End()
|
sel2 := sel.ContentsFiltered(".hero-unit").End()
|
||||||
@@ -102,6 +117,11 @@ func TestParentFiltered(t *testing.T) {
|
|||||||
assertClass(t, sel, "hero-unit")
|
assertClass(t, sel, "hero-unit")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParentFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".container-fluid").ParentFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParentFilteredRollback(t *testing.T) {
|
func TestParentFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.ParentFiltered(".hero-unit").End()
|
sel2 := sel.ParentFiltered(".hero-unit").End()
|
||||||
@@ -130,6 +150,11 @@ func TestParentsFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 1)
|
assertLength(t, sel.Nodes, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParentsFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".container-fluid").ParentsFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParentsFilteredRollback(t *testing.T) {
|
func TestParentsFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.ParentsFiltered("body").End()
|
sel2 := sel.ParentsFiltered("body").End()
|
||||||
@@ -141,6 +166,11 @@ func TestParentsUntil(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 6)
|
assertLength(t, sel.Nodes, 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParentsUntilInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".container-fluid").ParentsUntil("")
|
||||||
|
assertLength(t, sel.Nodes, 666) // TODO : ?
|
||||||
|
}
|
||||||
|
|
||||||
func TestParentsUntilRollback(t *testing.T) {
|
func TestParentsUntilRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.ParentsUntil("body").End()
|
sel2 := sel.ParentsUntil("body").End()
|
||||||
@@ -180,6 +210,11 @@ func TestParentsFilteredUntil(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 2)
|
assertLength(t, sel.Nodes, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParentsFilteredUntilInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".container-fluid").ParentsFilteredUntil("", "")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParentsFilteredUntilRollback(t *testing.T) {
|
func TestParentsFilteredUntilRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.ParentsFilteredUntil(".pvk-content", "body").End()
|
sel2 := sel.ParentsFilteredUntil(".pvk-content", "body").End()
|
||||||
@@ -240,6 +275,11 @@ func TestSiblingsFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 3)
|
assertLength(t, sel.Nodes, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSiblingsFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".pvk-gutter").SiblingsFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSiblingsFilteredRollback(t *testing.T) {
|
func TestSiblingsFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-gutter")
|
sel := Doc().Find(".pvk-gutter")
|
||||||
sel2 := sel.SiblingsFiltered(".pvk-content").End()
|
sel2 := sel.SiblingsFiltered(".pvk-content").End()
|
||||||
@@ -272,6 +312,11 @@ func TestNextFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 2)
|
assertLength(t, sel.Nodes, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNextFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".container-fluid").NextFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestNextFilteredRollback(t *testing.T) {
|
func TestNextFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.NextFiltered("div").End()
|
sel2 := sel.NextFiltered("div").End()
|
||||||
@@ -310,6 +355,11 @@ func TestPrevFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 5)
|
assertLength(t, sel.Nodes, 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrevFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".row-fluid").PrevFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrevFilteredRollback(t *testing.T) {
|
func TestPrevFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".row-fluid")
|
sel := Doc().Find(".row-fluid")
|
||||||
sel2 := sel.PrevFiltered(".row-fluid").End()
|
sel2 := sel.PrevFiltered(".row-fluid").End()
|
||||||
@@ -342,6 +392,11 @@ func TestNextAllFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 2)
|
assertLength(t, sel.Nodes, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNextAllFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("#cf2 .row-fluid").NextAllFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestNextAllFilteredRollback(t *testing.T) {
|
func TestNextAllFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find("#cf2 .row-fluid")
|
sel := Doc().Find("#cf2 .row-fluid")
|
||||||
sel2 := sel.NextAllFiltered("[ng-cloak]").End()
|
sel2 := sel.NextAllFiltered("[ng-cloak]").End()
|
||||||
@@ -380,6 +435,11 @@ func TestPrevAllFiltered(t *testing.T) {
|
|||||||
assertLength(t, sel.Nodes, 3)
|
assertLength(t, sel.Nodes, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrevAllFilteredInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".pvk-gutter").PrevAllFiltered("")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrevAllFilteredRollback(t *testing.T) {
|
func TestPrevAllFilteredRollback(t *testing.T) {
|
||||||
sel := Doc().Find(".pvk-gutter")
|
sel := Doc().Find(".pvk-gutter")
|
||||||
sel2 := sel.PrevAllFiltered(".pvk-content").End()
|
sel2 := sel.PrevAllFiltered(".pvk-content").End()
|
||||||
@@ -392,6 +452,11 @@ func TestNextUntil(t *testing.T) {
|
|||||||
assertSelectionIs(t, sel, "h4")
|
assertSelectionIs(t, sel, "h4")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNextUntilInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".alert a").NextUntil("")
|
||||||
|
assertLength(t, sel.Nodes, 100) // TODO : ?
|
||||||
|
}
|
||||||
|
|
||||||
func TestNextUntil2(t *testing.T) {
|
func TestNextUntil2(t *testing.T) {
|
||||||
sel := Doc().Find("#cf2-1").NextUntil("[ng-cloak]")
|
sel := Doc().Find("#cf2-1").NextUntil("[ng-cloak]")
|
||||||
assertLength(t, sel.Nodes, 1)
|
assertLength(t, sel.Nodes, 1)
|
||||||
@@ -446,6 +511,11 @@ func TestPrevUntil(t *testing.T) {
|
|||||||
assertSelectionIs(t, sel, "h4")
|
assertSelectionIs(t, sel, "h4")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrevUntilInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find(".alert p").PrevUntil("")
|
||||||
|
assertLength(t, sel.Nodes, 100) // TODO : ?
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrevUntil2(t *testing.T) {
|
func TestPrevUntil2(t *testing.T) {
|
||||||
sel := Doc().Find("[ng-cloak]").PrevUntil(":not([ng-cloak])")
|
sel := Doc().Find("[ng-cloak]").PrevUntil(":not([ng-cloak])")
|
||||||
assertLength(t, sel.Nodes, 1)
|
assertLength(t, sel.Nodes, 1)
|
||||||
@@ -500,6 +570,11 @@ func TestNextFilteredUntil(t *testing.T) {
|
|||||||
assertSelectionIs(t, sel, "#n3", "#n5", "#nf3", "#nf5")
|
assertSelectionIs(t, sel, "#n3", "#n5", "#nf3", "#nf5")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNextFilteredUntilInvalid(t *testing.T) {
|
||||||
|
sel := Doc2().Find(".two").NextFilteredUntil("", "")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestNextFilteredUntilRollback(t *testing.T) {
|
func TestNextFilteredUntilRollback(t *testing.T) {
|
||||||
sel := Doc2().Find(".two")
|
sel := Doc2().Find(".two")
|
||||||
sel2 := sel.NextFilteredUntil(".even", ".six").End()
|
sel2 := sel.NextFilteredUntil(".even", ".six").End()
|
||||||
@@ -542,6 +617,11 @@ func TestPrevFilteredUntil(t *testing.T) {
|
|||||||
assertSelectionIs(t, sel, "#n4", "#n2", "#nf4", "#nf2")
|
assertSelectionIs(t, sel, "#n4", "#n2", "#nf4", "#nf2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrevFilteredUntilInvalid(t *testing.T) {
|
||||||
|
sel := Doc2().Find(".five").PrevFilteredUntil("", "")
|
||||||
|
assertLength(t, sel.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrevFilteredUntilRollback(t *testing.T) {
|
func TestPrevFilteredUntilRollback(t *testing.T) {
|
||||||
sel := Doc2().Find(".four")
|
sel := Doc2().Find(".four")
|
||||||
sel2 := sel.PrevFilteredUntil(".odd", ".one").End()
|
sel2 := sel.PrevFilteredUntil(".odd", ".one").End()
|
||||||
@@ -598,6 +678,12 @@ func TestClosestNone(t *testing.T) {
|
|||||||
assertLength(t, sel2.Nodes, 0)
|
assertLength(t, sel2.Nodes, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClosestInvalid(t *testing.T) {
|
||||||
|
sel := Doc().Find("h4")
|
||||||
|
sel2 := sel.Closest("")
|
||||||
|
assertLength(t, sel2.Nodes, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func TestClosestMany(t *testing.T) {
|
func TestClosestMany(t *testing.T) {
|
||||||
sel := Doc().Find(".container-fluid")
|
sel := Doc().Find(".container-fluid")
|
||||||
sel2 := sel.Closest(".pvk-content")
|
sel2 := sel.Closest(".pvk-content")
|
||||||
|
Reference in New Issue
Block a user