Sha256: b77ccde81ed7590c1c340a639e80cdd3660be99990037cff420a87d3825779f4

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

if opal?
describe 'Element' do
  after(:each) do
    React::API.clear_component_class_cache
  end

  it 'renders a top level component using render with a block' do
    stub_const 'Foo', Class.new(React::Component::Base)
    Foo.class_eval do
      param :name
      def render
        "hello #{params.name}"
      end
    end
    test_div = Element.new(:div)
    test_div.render { Foo(name: 'fred') }
    expect(Element[test_div].find('span').html).to eq('hello fred')
  end

  it 'renders a top level component using render with a container and params ' do
    test_div = Element.new(:div)
    test_div.render(:span, id: :render_test_span) { 'hello' }
    expect(Element[test_div].find('#render_test_span').html).to eq('hello')
  end

  it 'will find the DOM node given a react element' do
    stub_const 'Foo', Class.new(React::Component::Base)
    Foo.class_eval do
      def render
        div { 'hello' }
      end
    end

    expect(Element[renderToDocument(Foo)].html).to eq('hello')
  end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reactrb-0.8.8 spec/react/opal_jquery_extensions_spec.rb
reactrb-0.8.7 spec/react/opal_jquery_extensions_spec.rb
reactrb-0.8.6 spec/react/opal_jquery_extensions_spec.rb
reactrb-0.8.5 spec/react/opal_jquery_extensions_spec.rb