Sha256: c895252c6c7fd70a88dd8251cfa793ad6e4bc00660ce942840f717a4c90c4c94

Contents?: true

Size: 736 Bytes

Versions: 2

Compression:

Stored size: 736 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("<span>working</span>")
    expect(Bar).to render("<span>working well</span>")
  end
end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
hyper-react-0.10.0 spec/react/component/base_spec.rb
reactrb-0.9.0 spec/react/component/base_spec.rb