Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added tests for stylesheet_url and javascript_url liquid tags

  • Loading branch information...
commit e39519f3ba6f6c7cc09d2e92526b8e9913261afe 1 parent 41472c8
Petr Blaho authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 spec/lib/locomotive/liquid/filters/html_spec.rb
View
37 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
Please sign in to comment.
Something went wrong with that request. Please try again.