Sha256: 2e206e4194dc8a2937c6b4cd595d16986675ef74254d6df4cf3383b314699abc

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

require 'test_helper'

class ConfigurableTest < ActiveSupport::TestCase

  ETC = ExpressTemplates::Components

  class ConfigurableComponent < ETC::Base
    include ETC::Capabilities::Configurable
    emits {
      div.bar(my[:id])
    }
  end

  test "a configurable component accepts an id argument" do
    assert :foo, ConfigurableComponent.new(:foo).my[:id]
  end

  test "renders id argument as dom id" do
    compiled_src = ConfigurableComponent.new(:foo).compile
    assert '<div id="foo" class="bar" />', compiled_src
  end

  class ConfigurableContainerComponent < ETC::Base
    include ETC::Capabilities::Configurable
    include ETC::Capabilities::Parenting

    # make sure a helper can take arguments
    helper(:name) {|name| name.to_s }

    emits {
      div(my[:id]) {
        h1 { name(my[:id]) }
        _yield
      }
    }
  end

  test "a configurable component may have also be a container" do
    html = ExpressTemplates.render { configurable_container_component(:foo) { p "bar" }}
    assert_equal '<div id="foo"><h1>foo</h1><p>bar</p></div>', html
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
express_templates-0.2.7 test/components/configurable_test.rb
express_templates-0.2.6 test/components/configurable_test.rb
express_templates-0.2.5 test/components/configurable_test.rb
express_templates-0.2.4 test/components/configurable_test.rb
express_templates-0.2.3 test/components/configurable_test.rb
express_templates-0.2.2 test/components/configurable_test.rb