github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/goquery/expand_test.go (about) 1 package goquery 2 3 import ( 4 "testing" 5 ) 6 7 func TestAdd(t *testing.T) { 8 sel := Doc().Find("div.row-fluid").Add("a") 9 AssertLength(t, sel.Nodes, 19) 10 } 11 12 func TestAddRollback(t *testing.T) { 13 sel := Doc().Find(".pvk-content") 14 sel2 := sel.Add("a").End() 15 AssertEqual(t, sel, sel2) 16 } 17 18 func TestAddSelection(t *testing.T) { 19 sel := Doc().Find("div.row-fluid") 20 sel2 := Doc().Find("a") 21 sel = sel.AddSelection(sel2) 22 AssertLength(t, sel.Nodes, 19) 23 } 24 25 func TestAddSelectionNil(t *testing.T) { 26 sel := Doc().Find("div.row-fluid") 27 AssertLength(t, sel.Nodes, 9) 28 29 sel = sel.AddSelection(nil) 30 AssertLength(t, sel.Nodes, 9) 31 } 32 33 func TestAddSelectionRollback(t *testing.T) { 34 sel := Doc().Find(".pvk-content") 35 sel2 := sel.Find("a") 36 sel2 = sel.AddSelection(sel2).End() 37 AssertEqual(t, sel, sel2) 38 } 39 40 func TestAddNodes(t *testing.T) { 41 sel := Doc().Find("div.pvk-gutter") 42 sel2 := Doc().Find(".pvk-content") 43 sel = sel.AddNodes(sel2.Nodes...) 44 AssertLength(t, sel.Nodes, 9) 45 } 46 47 func TestAddNodesNone(t *testing.T) { 48 sel := Doc().Find("div.pvk-gutter").AddNodes() 49 AssertLength(t, sel.Nodes, 6) 50 } 51 52 func TestAddNodesRollback(t *testing.T) { 53 sel := Doc().Find(".pvk-content") 54 sel2 := sel.Find("a") 55 sel2 = sel.AddNodes(sel2.Nodes...).End() 56 AssertEqual(t, sel, sel2) 57 } 58 59 func TestAndSelf(t *testing.T) { 60 sel := Doc().Find(".span12").Last().AndSelf() 61 AssertLength(t, sel.Nodes, 2) 62 } 63 64 func TestAndSelfRollback(t *testing.T) { 65 sel := Doc().Find(".pvk-content") 66 sel2 := sel.Find("a").AndSelf().End().End() 67 AssertEqual(t, sel, sel2) 68 }