add Index() methods

This commit is contained in:
Martin Angers
2012-08-30 17:24:18 -04:00
parent fe36d7039a
commit 85ad689f6a
3 changed files with 93 additions and 4 deletions

View File

@@ -93,3 +93,39 @@ func TestGetInvalid(t *testing.T) {
sel := doc.Find(".pvk-content")
sel.Get(129)
}
func TestIndex(t *testing.T) {
sel := doc.Find(".pvk-content")
if i := sel.Index(); i != 1 {
t.Errorf("Expected index of 1, got %v.", i)
}
}
func TestIndexSelector(t *testing.T) {
sel := doc.Find(".hero-unit")
if i := sel.IndexSelector("div"); i != 4 {
t.Errorf("Expected index of 4, got %v.", i)
}
}
func TestIndexOfNode(t *testing.T) {
sel := doc.Find("div.pvk-gutter")
if i := sel.IndexOfNode(sel.Nodes[1]); i != 1 {
t.Errorf("Expected index of 1, got %v.", i)
}
}
func TestIndexOfNilNode(t *testing.T) {
sel := doc.Find("div.pvk-gutter")
if i := sel.IndexOfNode(nil); i != -1 {
t.Errorf("Expected index of -1, got %v.", i)
}
}
func TestIndexOfSelection(t *testing.T) {
sel := doc.Find("div")
sel2 := doc.Find(".hero-unit")
if i := sel.IndexOfSelection(sel2); i != 4 {
t.Errorf("Expected index of 4, got %v.", i)
}
}