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
Term1: |
def1 |
Term2: |
def2 |
Term3: |
def3 |
HTML
DEFTABLE_MARKUP_ARR = <<-HTML
Field1: |
{{resource.field1}} |
Field2: |
{{resource.field2}} |
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