Sha256: c02f3e9da336674b30d63888e713208620d3ba0545aceac7f4159fee06ec39eb

Contents?: true

Size: 823 Bytes

Versions: 8

Compression:

Stored size: 823 Bytes

Contents

require 'spec_helper'

describe 'React::Component::Base', js: true do

  before :each do
    on_client do
      class Foo < React::Component::Base
        before_mount do
          @instance_data = ["working"]
        end
        def render
          @instance_data.first
        end
      end
    end
  end

  it 'can create a simple component class' do
    mount 'Foo'
    expect(page.body[-50..-19]).to match(/<span>working<\/span>/)
  end

  it 'can create a simple component class that can be inherited to create another component class' do
    mount 'Bar' do
      class Bar < Foo
        before_mount do
          @instance_data << "well"
        end
        def render
          @instance_data.join(" ")
        end
      end
    end
    expect(page.body[-50..-19]).to match(/<span>working well<\/span>/)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyper-react-1.0.0.lap28 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap27 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap26 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap25 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap24 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap23 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap22 spec/react/component/base_spec.rb
hyper-react-1.0.0.lap21 spec/react/component/base_spec.rb