require 'helper'
class TestSplatPrefixOption < TestSlim
def prefixes
['*','**','*!','*%','*^','*$']
end
def options(prefix)
{ splat_prefix: prefix }
end
def test_splat_without_content
prefixes.each do |prefix|
source = %Q{
#{prefix}hash
p#{prefix}hash
}
assert_html '
', source, options(prefix)
end
end
def test_shortcut_splat
prefixes.each do |prefix|
source = %Q{
#{prefix}hash This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat
prefixes.each do |prefix|
source = %Q{
h1 #{prefix}hash class=[] This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_closed_splat
prefixes.each do |prefix|
source = %Q{
#{prefix}hash /
}
assert_html '', source, options(prefix)
end
end
def test_splat_tag_name
prefixes.each do |prefix|
source = %Q{
#{prefix}{tag: 'h1', id: 'title'} This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_empty_tag_name
prefixes.each do |prefix|
source = %Q{
#{prefix}{tag: '', id: 'test'} This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_closed_splat_tag
prefixes.each do |prefix|
source = %Q{
#{prefix}hash /
}
assert_html '', source, options(prefix)
end
end
def test_splat_with_id_shortcut
prefixes.each do |prefix|
source = %Q{
#myid#{prefix}hash This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_with_class_shortcut
prefixes.each do |prefix|
source = %Q{
.myclass#{prefix}hash This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_with_id_and_class_shortcuts
prefixes.each do |prefix|
source = %Q{
#myid.myclass#{prefix}hash This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_with_class_merging
prefixes.each do |prefix|
source = %Q{
#myid.myclass #{prefix}{class: [:secondclass, %w(x y z)]} #{prefix}hash This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_with_boolean_attribute
prefixes.each do |prefix|
source = %Q{
#{prefix}{disabled: true, empty1: false, nonempty: '', empty2: nil} This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_merging_with_arrays
prefixes.each do |prefix|
source = %Q{
#{prefix}{a: 1, b: 2} #{prefix}[[:c, 3], [:d, 4]] #{prefix}[[:e, 5], [:f, 6]] This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
def test_splat_with_other_attributes
prefixes.each do |prefix|
source = %Q{
h1 data-id="123" #{prefix}hash This is my title
}
assert_html 'This is my title
', source, options(prefix)
end
end
end