Sha256: 8e2c477f413598929c69b29a9496eb0152832e7aac504f15d12de48e244785ec

Contents?: true

Size: 760 Bytes

Versions: 9

Compression:

Stored size: 760 Bytes

Contents

require 'spec_helper'

if opal?
RSpec.describe React::Component::Base, type: :component 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(Foo).to render_static_html("<span>working</span>")
    expect(Bar).to render_static_html("<span>working well</span>")
  end
end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyper-react-0.12.7 spec/react/component/base_spec.rb
hyper-react-0.12.6 spec/react/component/base_spec.rb
hyper-react-0.12.5 spec/react/component/base_spec.rb
hyper-react-0.12.4 spec/react/component/base_spec.rb
hyper-react-0.12.3 spec/react/component/base_spec.rb
hyper-react-0.12.2 spec/react/component/base_spec.rb
hyper-react-0.12.1 spec/react/component/base_spec.rb
hyper-react-0.12.0 spec/react/component/base_spec.rb
hyper-react-0.11.0 spec/react/component/base_spec.rb