forked from bimovidia/stroke-seven-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicon_helper_test.rb
50 lines (38 loc) · 1.68 KB
/
icon_helper_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require 'test_helper'
class StrokeSeven::Rails::IconHelperTest < ActionView::TestCase
test "#s7_icon with no args should render an album icon" do
assert_icon i("pe-7s-album")
end
test "#s7_icon should render different individual icons" do
assert_icon i("pe-7s-album"), "album"
assert_icon i("pe-7s-female"), "female"
assert_icon i("pe-7s-magic-wand"), "magic-wand"
end
test "#s7_icon should incorporate additional class styles" do
assert_icon i("pe-7s-album pull-right"), "album", :class => "pull-right"
assert_icon i("pe-7s-album pull-right success"), "album", :class => "pull-right success"
end
test "#s7_icon should incorporate a text suffix" do
assert_icon "#{i("pe-7s-female")} Take a photo", "female", :text => "Take a photo"
end
test "#s7_icon should html escape text" do
assert_icon "#{i("pe-7s-female")} <script></script>", "female", :text => "<script></script>"
end
test "#s7_icon should not html escape safe text" do
assert_icon "#{i("pe-7s-female")} <script></script>", "female", :text => "<script></script>".html_safe
end
test "#s7_icon should pull it all together" do
assert_icon "#{i("pe-7s-female pull-right")} Take a photo", "female", :text => "Take a photo", :class => "pull-right"
end
test "#s7_icon should pass all other options through" do
assert_icon %(<i class="pe-7s-male" data-id="123"></i>), "male", :data => { :id => 123 }
end
private
def assert_icon(expected, *args)
message = "`s7_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
assert_dom_equal expected, s7_icon(*args), message
end
def i(classes)
%(<i class="#{classes}"></i>)
end
end