Sha256: 0c1ac22fce0a95549262dde5039bf4b5d8f297cf5ddc8dc61e6485ebc20b9196

Contents?: true

Size: 759 Bytes

Versions: 16

Compression:

Stored size: 759 Bytes

Contents

require "spec_helper"

describe "Element#at" do
  html <<-HTML
    <div class="foo" id="blah"></div>
    <div class="foo" id="bleh"></div>
    <div class="foo" id="bluh"></div>
  HTML

  it "returns the element at the given index" do
    foos = Element.find '.foo'
    foos.length.should == 3

    foos.at(0).id.should == "blah"
    foos.at(1).id.should == "bleh"
    foos.at(2).id.should == "bluh"
  end

  it "counts from the last index for negative values" do
    foos = Element.find '.foo'

    foos.at(-1).id.should == "bluh"
    foos.at(-2).id.should == "bleh"
    foos.at(-3).id.should == "blah"
  end

  it "returns nil for indexes outside range" do
    foos = Element.find '.foo'

    foos.at(-4).should == nil
    foos.at(4).should == nil
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
opal-jquery-0.4.2 spec/element/at_spec.rb
opal-jquery-0.4.1 spec/element/at_spec.rb
opal-jquery-0.4.0 spec/element/at_spec.rb
opal-jquery-0.3.0 spec/element/at_spec.rb
opal-jquery-0.3.0.beta2 spec/element/at_spec.rb
opal-jquery-0.3.0.beta1 spec/element/at_spec.rb
opal-jquery-0.2.0 spec/element/at_spec.rb
opal-jquery-0.1.2 spec/element/at_spec.rb
opal-jquery-0.1.1 spec/element/at_spec.rb
opal-jquery-0.1.0 spec/element/at_spec.rb
opal-jquery-0.0.13 spec/element/at_spec.rb
opal-jquery-0.0.12 spec/element/at_spec.rb
opal-jquery-0.0.11 spec/element/at_spec.rb
opal-jquery-0.0.9 spec/element/at_spec.rb
opal-jquery-0.0.8 spec/element/at_spec.rb
opal-jquery-0.0.7 spec/element/at_spec.rb