Sha256: f404a8bc64e2462dfdf94df2a16282939e0128d59fc7587f8e4c7f085ba34cf9

Contents?: true

Size: 1.06 KB

Versions: 12

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

12 entries across 12 versions & 2 rubygems

Version Path
express_admin-1.2.1 vendor/gems/express_templates/test/components/configurable_test.rb
express_admin-1.2.0 vendor/gems/express_templates/test/components/configurable_test.rb
express_templates-0.5.0 test/components/configurable_test.rb
express_templates-0.4.2 test/components/configurable_test.rb
express_templates-0.4.1 test/components/configurable_test.rb
express_templates-0.4.0 test/components/configurable_test.rb
express_templates-0.3.6 test/components/configurable_test.rb
express_templates-0.3.5 test/components/configurable_test.rb
express_templates-0.3.4 test/components/configurable_test.rb
express_templates-0.3.2 test/components/configurable_test.rb
express_templates-0.3.1 test/components/configurable_test.rb
express_templates-0.3.0 test/components/configurable_test.rb