Sha256: f3297948ff0c6bdfcee3a4434fda7b04c5dacc5ff5a3fbf361f141e2491a8170

Contents?: true

Size: 1.41 KB

Versions: 20

Compression:

Stored size: 1.41 KB

Contents

require 'test_helper'

module ExpressAdmin

  class DefinitionTableTest < ActiveSupport::TestCase

    def assigns
      {list_types: list_types}
    end

    def helpers
      mock_action_view
    end

    def list_types
      @list_types ||= OpenStruct.new(
        array: ["field1", "field2"],
        hash: {term1: "def1",
               term2: "def2",
               term3: "def3"})
    end 

    def deftable(*args)
      arbre {
        definition_table(:deftable, *args)
      }.to_s
    end

    DEFTABLE_MARKUP = <<-HTML
<table class="definition-table" id="deftable">
  <tbody>
    <tr>
      <th align="right">Term1:</th>
      <td>def1</td>
    </tr>
    <tr>
      <th align="right">Term2:</th>
      <td>def2</td>
    </tr>
    <tr>
      <th align="right">Term3:</th>
      <td>def3</td>
    </tr>
  </tbody>
</table>
HTML

    DEFTABLE_MARKUP_ARR = <<-HTML
<table class="definition-table" id="deftable">
  <tbody>
    <tr>
      <th align="right">Field1:</th>
      <td>{{resource.field1}}</td>
    </tr>
    <tr>
      <th align="right">Field2:</th>
      <td>{{resource.field2}}</td>
    </tr>
  </tbody>
</table>
HTML

    test "definition_table renders correct markup with hash input" do
      assert_equal DEFTABLE_MARKUP, deftable(list_types[:hash])
    end

    test "definition_table renders correct markup with array input" do
      assert_equal DEFTABLE_MARKUP_ARR, deftable(list_types[:array])
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
express_admin-1.7.7 test/dummy/test/components/definition_table_test.rb
express_admin-1.7.5 test/dummy/test/components/definition_table_test.rb
express_admin-1.7.4 test/dummy/test/components/definition_table_test.rb
express_admin-1.7.3 test/dummy/test/components/definition_table_test.rb
express_admin-1.7.2 test/dummy/test/components/definition_table_test.rb
express_admin-1.7.1 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.13 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.12 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.11 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.10 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.9 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.8 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.7 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.4 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.3 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.2 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.1 test/dummy/test/components/definition_table_test.rb
express_admin-1.6.0 test/dummy/test/components/definition_table_test.rb
express_admin-1.5.0 test/dummy/test/components/definition_table_test.rb
express_admin-1.4.11 test/dummy/test/components/definition_table_test.rb