require 'spec_helper' describe Locomotive::Liquid::Filters::Html do include Locomotive::Liquid::Filters::Html before(:each) do @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 that starts with "/"' do result = "/trash/main.css" stylesheet_url('/trash/main.css').should == result stylesheet_url('/trash/main').should == result end it 'should return a url for a stylesheet file without touching the url that starts with "http:"' do result = "http://cdn.example.com/trash/main.css" stylesheet_url('http://cdn.example.com/trash/main.css').should == result stylesheet_url('http://cdn.example.com/trash/main').should == result end it 'should return a url for a stylesheet file without touching the url that starts with "https:"' do result = "https://cdn.example.com/trash/main.css" stylesheet_url('https://cdn.example.com/trash/main.css').should == result stylesheet_url('https://cdn.example.com/trash/main').should == result end it 'should return a link tag for a stylesheet file' do result = "" stylesheet_tag('main.css').should == result stylesheet_tag('main').should == result stylesheet_tag(nil).should == '' end it 'should return a link tag for a stylesheet file with folder' do result = "" stylesheet_tag('trash/main.css').should == result end it 'should return a link tag for a stylesheet file without touching the url that starts with "/"' do result = "" stylesheet_tag('/trash/main.css').should == result stylesheet_tag('/trash/main').should == result end it 'should return a link tag for a stylesheet file without touching the url that starts with "http:"' do result = "" stylesheet_tag('http://cdn.example.com/trash/main.css').should == result stylesheet_tag('http://cdn.example.com/trash/main').should == result end it 'should return a link tag for a stylesheet file without touching the url that starts with "https:"' do result = "" stylesheet_tag('https://cdn.example.com/trash/main.css').should == result stylesheet_tag('https://cdn.example.com/trash/main').should == result end it 'should return a link tag for a stylesheet file and media attribute set to print' do result = "" stylesheet_tag('main.css','print').should == result stylesheet_tag('main','print').should == result stylesheet_tag(nil).should == '' end it 'should return a link tag for a stylesheet file with folder and media attribute set to print' do result = "" stylesheet_tag('trash/main.css','print').should == result end it 'should return a link tag for a stylesheet file without touching the url that starts with "/" and media attribute set to print' do result = "" stylesheet_tag('/trash/main.css','print').should == result stylesheet_tag('/trash/main','print').should == result end it 'should return a link tag for a stylesheet file without touching the url that starts with "http:" and media attribute set to print' do result = "" stylesheet_tag('http://cdn.example.com/trash/main.css','print').should == result stylesheet_tag('http://cdn.example.com/trash/main','print').should == result end it 'should return a link tag for a stylesheet file without touching the url that starts with "https:" and media attribute set to print' do result = "" stylesheet_tag('https://cdn.example.com/trash/main.css','print').should == result stylesheet_tag('https://cdn.example.com/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 that starts with "/"' do result = "/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 that starts with "http:"' do result = "http://cdn.example.com/trash/main.js" javascript_url('http://cdn.example.com/trash/main.js').should == result javascript_url('http://cdn.example.com/trash/main').should == result end it 'should return a url for a javascript file without touching the url that starts with "https:"' do result = "https://cdn.example.com/trash/main.js" javascript_url('https://cdn.example.com/trash/main.js').should == result javascript_url('https://cdn.example.com/trash/main').should == result end it 'should return a script tag for a javascript file' do result = %{} javascript_tag('main.js').should == result javascript_tag('main').should == result javascript_tag(nil).should == '' end it 'should return a script tag for a javascript file with folder' do result = %{} javascript_tag('trash/main.js').should == result javascript_tag('trash/main').should == result end it 'should return a script tag for a javascript file without touching the url that starts with "/"' do result = %{} javascript_tag('/trash/main.js').should == result javascript_tag('/trash/main').should == result end it 'should return a script tag for a javascript file without touching the url that starts with "http:"' do result = %{} javascript_tag('http://cdn.example.com/trash/main.js').should == result javascript_tag('http://cdn.example.com/trash/main').should == result end it 'should return a script tag for a javascript file without touching the url that starts with "https:"' do result = %{} javascript_tag('https://cdn.example.com/trash/main.js').should == result javascript_tag('https://cdn.example.com/trash/main').should == result end it 'should return an image tag for a given theme file without parameters' do theme_image_tag('foo.jpg').should == "" end it 'should return an image tag for a given theme file with size' do theme_image_tag('foo.jpg', 'width:100', 'height:100').should == "" end it 'should return an image tag without parameters' do image_tag('foo.jpg').should == "" end it 'should return an image tag with size' do image_tag('foo.jpg', 'width:100', 'height:50').should == "" end it 'should return a flash tag without parameters' do flash_tag('foo.flv').should == %{ }.strip end it 'should return a flash tag with size' do flash_tag('foo.flv', 'width:100', 'height:50').should == %{ }.strip end it 'should return a navigation block for the pagination' do pagination = { "previous" => nil, "parts" => [ { 'title' => '1', 'is_link' => false }, { 'title' => '2', 'is_link' => true, 'url' => '/?page=2' }, { 'title' => '…', 'is_link' => false, 'hellip_break' => true }, { 'title' => '5', 'is_link' => true, 'url' => '/?page=5' } ], "next" => { 'title' => 'next', 'is_link' => true, 'url' => '/?page=2' } } html = default_pagination(pagination, 'css:flickr_pagination') html.should match(/