Permalink
Browse files

Added tests for stylesheet_url and javascript_url liquid tags

  • Loading branch information...
1 parent 41472c8 commit e39519f3ba6f6c7cc09d2e92526b8e9913261afe Petr Blaho committed Jul 19, 2011
Showing with 37 additions and 0 deletions.
  1. +37 −0 spec/lib/locomotive/liquid/filters/html_spec.rb
@@ -8,6 +8,24 @@
@context = build_context
end
+ it 'should return a url for a stylesheet file' do
+ result = "/sites/000000000000000000000042/theme/stylesheets/main.css"
+ stylesheet_url('main.css').should == result
+ stylesheet_url('main').should == result
+ stylesheet_url(nil).should == ''
+ end
+
+ it 'should return a url for a stylesheet file with folder' do
+ result = "/sites/000000000000000000000042/theme/stylesheets/trash/main.css"
+ stylesheet_url('trash/main.css').should == result
+ end
+
+ it 'should return a url for a stylesheet file without touching the url' do
+ result = "/trash/main.css"
+ stylesheet_url('/trash/main.css').should == result
+ stylesheet_url('/trash/main').should == result
+ end
+
it 'should return a link tag for a stylesheet file' do
result = "<link href=\"/sites/000000000000000000000042/theme/stylesheets/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
stylesheet_tag('main.css').should == result
@@ -44,6 +62,25 @@
stylesheet_tag('/trash/main','print').should == result
end
+ it 'should return a url for a javascript file' do
+ result = "/sites/000000000000000000000042/theme/javascripts/main.js"
+ javascript_url('main.js').should == result
+ javascript_url('main').should == result
+ javascript_url(nil).should == ''
+ end
+
+ it 'should return a url for a javascript file with folder' do
+ result = "/sites/000000000000000000000042/theme/javascripts/trash/main.js"
+ javascript_url('trash/main.js').should == result
+ javascript_url('trash/main').should == result
+ end
+
+ it 'should return a url for a javascript file without touching the url' do
+ result = "/trash/main.js"
+ javascript_url('/trash/main.js').should == result
+ javascript_url('/trash/main').should == result
+ end
+
it 'should return a script tag for a javascript file' do
result = %{<script src="/sites/000000000000000000000042/theme/javascripts/main.js" type="text/javascript"></script>}
javascript_tag('main.js').should == result

0 comments on commit e39519f

Please sign in to comment.