Sha256: 7be58228fe4683e90beb4d4b3e70bb4ada0acd0bdb6bd19840bd6b4833ac25d3

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

if RUBY_ENGINE == 'opal' 
  RSpec.describe React::Test::DSL do
    describe 'the DSL' do
      let(:session) { Class.new { include React::Test::DSL }.new }

      before do
        React::Test.reset_session!

        stub_const 'Greeter', Class.new
        Greeter.class_eval do
          include React::Component

          params do
            optional :message
            optional :from
          end

          def render
            span { "Hello #{params.message}" }
          end
        end
      end

      it 'is possible to include it in another class' do
        session.mount(Greeter)
        expect(session.instance).to be_a(Greeter)
      end

      it "should provide a 'component' shortcut for more expressive tests" do
        session.component.mount(Greeter)
        expect(session.component.instance).to be_a(Greeter)
      end

      React::Test::Session::DSL_METHODS.each do |method|
        it "responds to all DSL method: #{method}" do
          expect(session).to respond_to(method)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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