Sha256: e08d015836035636ba439d7b268e616b9a884aa8d4bdb0a147502d184538d7b6

Contents?: true

Size: 1.15 KB

Versions: 22

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe Inesita::Component do
  let(:empty_component) { Class.new { include Inesita::Component }}
  let(:component) do
    Class.new do
      include Inesita::Component

      def render
        h1 class: 'test' do
          'Test'
        end
      end
    end
  end

  let(:nested_component) do
    Class.new do
      include Inesita::Component

      Inner = Class.new do
        include Inesita::Component

        def render
          div do
            'Inner'
          end
        end
      end

      def render
        h1 class: 'test' do
          component Inner
        end
      end
    end
  end

  let(:element) do
    Inesita::Browser::Document.JS.createElement('div')
  end

  it 'should fail when no #render method' do
    expect { empty_component.new.mount_to(element) }.to raise_error Inesita::Error
  end

  it 'should render html' do
    component.new.mount_to(element)
    expect(element.JS[:innerHTML]).to eq '<h1 class="test">Test</h1>'
  end

  it 'should render html with nested components' do
    nested_component.new.mount_to(element)
    expect(element.JS[:innerHTML]).to eq '<h1 class="test"><div>Inner</div></h1>'
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
inesita-1.0.pre.9 spec/opal/component_spec.rb
inesita-1.0.pre.8 spec/opal/component_spec.rb
inesita-1.0.pre.7 spec/opal/component_spec.rb
inesita-1.0.pre.6 spec/opal/component_spec.rb
inesita-1.0.pre.5 spec/opal/component_spec.rb
inesita-1.0.pre.4 spec/opal/component_spec.rb
inesita-1.0.pre.3 spec/opal/component_spec.rb
inesita-1.0.pre.2 spec/opal/component_spec.rb
inesita-1.0.pre.1 spec/opal/component_spec.rb
inesita-0.9.2 spec/opal/component_spec.rb
inesita-0.9.1 spec/opal/component_spec.rb
inesita-0.9.0 spec/opal/component_spec.rb
inesita-0.8.2 spec/opal/component_spec.rb
inesita-0.8.1 spec/opal/component_spec.rb
inesita-0.7.0 spec/opal/component_spec.rb
inesita-0.6.1 spec/opal/component_spec.rb
inesita-0.6.0 spec/opal/component_spec.rb
inesita-0.6.0.beta.1 spec/opal/component_spec.rb
inesita-0.5.1 spec/opal/component_spec.rb
inesita-0.5.0 spec/opal/component_spec.rb