gem.gems.haml-3.1.1.test.haml.html2haml_test.rb Maven / Gradle / Ivy
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../test_helper'
require File.dirname(__FILE__) + '/html2haml/erb_tests'
require 'haml/html'
class Html2HamlTest < Test::Unit::TestCase
def test_empty_render_should_remain_empty
assert_equal '', render('')
end
def test_doctype
assert_equal '!!!', render("")
assert_equal '!!! 1.1', render('')
assert_equal '!!! Strict', render('')
assert_equal '!!! Frameset', render('')
assert_equal '!!! Mobile 1.2', render('')
assert_equal '!!! Basic 1.1', render('')
assert_equal '!!!', render('')
assert_equal '!!! Strict', render('')
assert_equal '!!! Frameset', render('')
assert_equal '!!!', render('')
end
def test_id_and_class_should_be_removed_from_hash
assert_equal '%span#foo.bar', render(' ')
assert_equal '.foo', render(' ')
end
def test_multiple_class_names
assert_equal '.foo.bar.baz', render(' ')
end
def test_should_have_pretty_attributes
assert_equal('%input{:name => "login", :type => "text"}/',
render(''))
assert_equal('%meta{:content => "text/html", "http-equiv" => "Content-Type"}/',
render(''))
end
def test_class_with_dot_and_hash
assert_equal('%div{:class => "foo.bar"}', render(""))
assert_equal('%div{:class => "foo#bar"}', render(""))
assert_equal('.foo.bar{:class => "foo#bar foo.bar"}', render(""))
end
def test_id_with_dot_and_hash
assert_equal('%div{:id => "foo.bar"}', render(""))
assert_equal('%div{:id => "foo#bar"}', render(""))
end
def test_interpolation
assert_equal('Foo \#{bar} baz', render('Foo #{bar} baz'))
end
def test_interpolation_in_attrs
assert_equal('%p{:foo => "\#{bar} baz"}', render(''))
end
def test_cdata
assert_equal(<
flop
HAML
flop
]]>
HTML
end
def test_self_closing_tag
assert_equal("%foo/", render(" "))
end
def test_inline_text
assert_equal("%p foo", render("foo
"))
end
def test_inline_comment
assert_equal("/ foo", render(""))
assert_equal(<
bar
HTML
end
def test_non_inline_comment
assert_equal(<
HTML
end
def test_non_inline_text
assert_equal(<
foo
HTML
assert_equal(<
foo
HTML
assert_equal(<foo
HTML
end
def test_script_tag
assert_equal(<
function foo() {
return "12" & "13";
}
HTML
end
def test_script_tag_with_cdata
assert_equal(<
HTML
end
def test_pre
assert_equal(<foo
bar
baz
')
end
def test_no_tag_name_for_div_if_class_or_id_is_present
assert_equal '#foo', render('
HTML
end
def test_pre_code
assert_equal(<foo
bar
baz
HTML
end
def test_code_without_pre
assert_equal(<- foo bar -
")) end def test_equals_in_tag assert_equal("%p = foo bar =", render("= foo bar =
")) end def test_hash_in_tag assert_equal("%p # foo bar #", render("# foo bar #
")) end def test_comma_post_tag assert_equal(<
Foo, bar
Foobar, baz
HTML
end
def test_comma_post_tag_with_text_before
assert_equal(<