Sha256: 726f2ce41efa149d377457f9eecfe12a8a2f1959ceb690d5aebef93dd0bcc3d3

Contents?: true

Size: 748 Bytes

Versions: 7

Compression:

Stored size: 748 Bytes

Contents

require "spec_helper"

RSpec.describe "Element#before" do
  html <<-HTML
    <div id="some-header" class="kapow"></div>
    <div id="foo" class="before-spec-first"></div>
    <div id="bar" class="before-spec-first"></div>
    <div id="baz"></div>
  HTML

  it "should insert the given html string before each element" do
    el = Element.find('.before-spec-first')
    el.size.should == 2

    el.before '<p class="woosh"></p>'

    Element.find('#foo').prev.class_name.should == "woosh"
    Element.find('#bar').prev.class_name.should == "woosh"
  end

  it "should insert the given DOM element before this element" do
    Element.find('#baz').before Element.find('#some-header')
    Element.find('#baz').prev.id.should == "some-header"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
opal-jquery-0.5.2 spec-opal/element/before_spec.rb
opal-jquery-0.5.1 spec-opal/element/before_spec.rb
opal-jquery-0.5.0 spec-opal/element/before_spec.rb
opal-jquery-0.4.6 spec-opal/element/before_spec.rb
opal-jquery-0.4.5 spec-opal/element/before_spec.rb
opal-jquery-0.4.4 spec-opal/element/before_spec.rb
opal-jquery-0.4.3 spec-opal/element/before_spec.rb