require 'test_helper'
class HtmlFormatTest < ActiveSupport::TestCase
setup do
HtmlFormat.default_options[:table_class] = ["foo"]
end
test "html_format" do
assert_nil html_format(nil)
assert_equal "
", html_format(1)
end
test "to_html" do
assert_equal "", 1.to_html
assert_nil [].to_html
assert_nil "".to_html
end
test "array of hash" do
v = [
{id: 1, name: "alice", created_at: "2000-01-01"},
{id: 2, name: "bob", created_at: "2000-01-02"},
{id: 3, name: "carol", created_at: "2000-01-03"},
]
assert_equal "", v.to_html
end
test "hash"do
v = {id: 1, name: "alice", created_at: "2000-01-01"}
assert_equal "", v.to_html
end
test "array of array" do
v = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
assert_equal "", v.to_html
end
test "array" do
assert_equal "", [0, 1, 2, 3].to_html
end
test "title option" do
assert_equal "", [0].to_html(title: "(title)")
end
end