Sha256: 26721198fdd8a0852e0021f2556723b24836e9034577cb227a6a88c39d78c4b2

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8

class Nanoc::Filters::YUICompressorTest < MiniTest::Unit::TestCase

  include Nanoc::TestHelpers

  def test_filter_javascript
    if_have 'yuicompressor' do
      filter = ::Nanoc::Filters::YUICompressor.new

      sample_js = <<-JAVASCRIPT
        function factorial(n) {
            var result = 1;
            for (var i = 2; i <= n; i++) {
                result *= i
            }
            return result;
        }
      JAVASCRIPT

      result = filter.run(sample_js, { :type => 'js', :munge => true })
      assert_match "function factorial(c){var a=1;for(var b=2;b<=c;b++){a*=b}return a};", result

      result = filter.run(sample_js, { :type => 'js', :munge => false })
      assert_match "function factorial(n){var result=1;for(var i=2;i<=n;i++){result*=i}return result};", result
    end
  end

  def test_filter_css
    if_have 'yuicompressor' do
      filter = ::Nanoc::Filters::YUICompressor.new

      sample_css = <<-CSS
        * {
          margin: 0;
        }
      CSS

      result = filter.run(sample_css, { :type => 'css' })
      assert_match "*{margin:0}", result
    end
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
nanoc-3.5.0 test/filters/test_yui_compressor.rb
nanoc-3.5.0b2 test/filters/test_yui_compressor.rb
nanoc-3.5.0b1 test/filters/test_yui_compressor.rb
nanoc-3.4.3 test/filters/test_yui_compressor.rb
nanoc-3.4.2 test/filters/test_yui_compressor.rb
nanoc-3.4.1 test/filters/test_yui_compressor.rb
nanoc-3.4.0 test/filters/test_yui_compressor.rb
nanoc-3.3.7 test/filters/test_yui_compressor.rb
nanoc-3.3.6 test/filters/test_yui_compressor.rb
nanoc-3.3.5 test/filters/test_yui_compressor.rb
nanoc-3.3.4 test/filters/test_yui_compressor.rb
nanoc-3.3.3 test/filters/test_yui_compressor.rb
nanoc-3.3.2 test/filters/test_yui_compressor.rb
nanoc-3.3.1 test/filters/test_yui_compressor.rb
nanoc-3.3.0 test/filters/test_yui_compressor.rb