Sha256: 2cde84505511179e478e2189382110b14314384f9b7b29f95606279895754b43

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

# encoding: utf-8

class Nanoc::Filters::YUICompressorTest < Nanoc::TestCase
  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.setup_and_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.setup_and_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.setup_and_run(sample_css, { type: 'css' })
      assert_match '*{margin:0}', result
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nanoc-4.0.0b2 test/filters/test_yui_compressor.rb
nanoc-4.0.0b1 test/filters/test_yui_compressor.rb
nanoc-4.0.0a2 test/filters/test_yui_compressor.rb
nanoc-4.0.0a1 test/filters/test_yui_compressor.rb
nanoc-3.8.0 test/filters/test_yui_compressor.rb
nanoc-3.7.5 test/filters/test_yui_compressor.rb