Sha256: 8335a11ce097bec42ee455b7a62ddb408a055e4a8142c4d34c77a10e44ec20ca

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

require 'spec_helper'

if opal?
describe React::Component::Base do
  after(:each) do
    React::API.clear_component_class_cache
  end

  it 'can be inherited to create a component class' do
    stub_const 'Foo', Class.new(React::Component::Base)
    Foo.class_eval do
      before_mount do
        @instance_data = ["working"]
      end
      def render
        @instance_data.first
      end
    end
    stub_const 'Bar', Class.new(Foo)
    Bar.class_eval do
      before_mount do
        @instance_data << "well"
      end
      def render
        @instance_data.join(" ")
      end
    end
    expect(React.render_to_static_markup(React.create_element(Foo))).to eq("<span>working</span>")
    expect(React.render_to_static_markup(React.create_element(Bar))).to eq("<span>working well</span>")
  end

end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reactive-ruby-0.7.33 spec/react/component_base_spec.rb
reactive-ruby-0.7.32 spec/react/component_base_spec.rb