Sha256: 0f435b26c9ce597b80e73c8c1a9b7faa7e9667cfe0f2f375f8d27c7d3fb299f0

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

RSpec.describe ReactiveRuby::ServerRendering::ContextualRenderer do
  let(:renderer) { described_class.new({}) }
  let(:init) { Proc.new {} }
  let(:options) { { context_initializer: init } }

  describe '#render' do
    it 'pre-renders HTML' do
      result = renderer.render('Components.Todo',
                                { todo: 'finish reactive-ruby' },
                                options)
      expect(result).to match(/<li.*>finish reactive-ruby<\/li>/)
      # react 16 does not generate checksum
      # expect(result).to match(/data-react-checksum/)
      expect(result).to match(/data-reactroot/)
    end

    it 'accepts props as a string' do
      result = renderer.render('Components.Todo',
                                { todo: 'finish reactive-ruby' }.to_json,
                                options)
      expect(result).to match(/<li.*>finish reactive-ruby<\/li>/)
            # react 16 does not generate checksum
      # expect(result).to match(/data-react-checksum/)
      expect(result).to match(/data-reactroot/)
    end

    it 'pre-renders static content' do
      result = renderer.render('Components.Todo',
                                { todo: 'finish reactive-ruby' },
                                :static)
      expect(result).to match(/<li.*>finish reactive-ruby<\/li>/)
      # react 16 does not generate checksum
      # expect(result).to_not match(/data-react-checksum/)
      expect(result).to_not match(/data-reactroot/)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyper-react-1.0.0.lap28 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap27 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap26 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap25 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap24 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap23 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap22 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb
hyper-react-1.0.0.lap21 spec/reactive-ruby/server_rendering/contextual_renderer_spec.rb