require 'test_helper'
class FontAwesome::Rails::IconHelperTest < ActionView::TestCase
test "#fa_icon with no args should render a flag icon" do
assert_icon i("fa fa-flag")
end
test "#fa_icon should render different individual icons" do
assert_icon i("fa fa-flag"), "flag"
assert_icon i("fa fa-camera-retro"), "camera-retro"
assert_icon i("fa fa-cog"), "cog"
assert_icon i("fa fa-github"), "github"
end
test "#fa_icon should render icons with multiple modifiers" do
assert_icon i("fa fa-pencil fa-fixed-width"), "pencil fixed-width"
assert_icon i("fa fa-flag fa-4x"), "flag 4x"
assert_icon i("fa fa-refresh fa-2x fa-spin"), "refresh 2x spin"
end
test "#fa_icon should render icons with array modifiers" do
assert_icon i("fa fa-flag"), ["flag"]
assert_icon i("fa fa-check fa-li"), ["check", "li"]
assert_icon i("fa fa-flag fa-4x"), ["flag", "4x"]
assert_icon i("fa fa-refresh fa-2x fa-spin"), ["refresh", "2x", "spin"]
end
test "#fa_icon should incorporate additional class styles" do
assert_icon i("fa fa-flag pull-right"), "flag", :class => "pull-right"
assert_icon i("fa fa-flag fa-2x pull-right"), ["flag", "2x"], :class => ["pull-right"]
assert_icon i("fa fa-check fa-li pull-right special"), "check li", :class => "pull-right special"
assert_icon i("fa fa-check pull-right special"), "check", :class => ["pull-right", "special"]
end
test "#fa_icon should incorporate a text suffix" do
assert_icon "#{i("fa fa-camera-retro")} Take a photo", "camera-retro", :text => "Take a photo"
end
test "#fa_icon should html escape text" do
assert_icon "#{i("fa fa-camera-retro")} <script></script>", "camera-retro", :text => ""
end
test "#fa_icon should not html escape safe text" do
assert_icon "#{i("fa fa-camera-retro")} ", "camera-retro", :text => "".html_safe
end
test "#fa_icon should pull it all together" do
assert_icon "#{i("fa fa-camera-retro pull-right")} Take a photo", "camera-retro", :text => "Take a photo", :class => "pull-right"
end
test "#fa_icon should pass all other options through" do
assert_icon %(), "user", :data => { :id => 123 }
end
test "#fa_stacked_icon with no args should render a flag icon" do
expected = %(#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-flag fa-stack-1x")})
assert_stacked_icon expected
end
test "#fa_stacked_icon should render a stacked icon" do
expected = %(#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")})
assert_stacked_icon expected, "twitter", :base => "square-o"
expected = %(#{i("fa fa-square fa-stack-2x")}#{i("fa fa-terminal fa-inverse fa-stack-1x")})
assert_stacked_icon expected, ["terminal", "inverse"], :base => ["square"]
end
test "#fa_stacked_icon should incorporate additional class styles" do
expected = %(#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")})
assert_stacked_icon expected, "twitter", :base => "square-o", :class => "pull-right"
end
test "#fa_stacked_icon should reverse the stack" do
expected = %(#{i("fa fa-facebook fa-stack-1x")}#{i("fa fa-ban fa-stack-2x")})
assert_stacked_icon expected, "facebook", :base => "ban", :reverse => "true"
end
test "#fa_stacked_icon should html escape text" do
expected = %(#{i("fa fa-check-empty fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")} <script>)
assert_stacked_icon expected, "twitter", :base => "check-empty", :text => "