Sha256: f9ab6578d68dafbcad8f5b4bb0770d063d5e36715804b21dbedf2d0fe6054b1b

Contents?: true

Size: 1.1 KB

Versions: 18

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'helper'

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

18 entries across 18 versions & 1 rubygems

Version Path
nanoc-4.8.12 test/filters/test_yui_compressor.rb
nanoc-4.8.11 test/filters/test_yui_compressor.rb
nanoc-4.8.10 test/filters/test_yui_compressor.rb
nanoc-4.8.9 test/filters/test_yui_compressor.rb
nanoc-4.8.8 test/filters/test_yui_compressor.rb
nanoc-4.8.7 test/filters/test_yui_compressor.rb
nanoc-4.8.6 test/filters/test_yui_compressor.rb
nanoc-4.8.5 test/filters/test_yui_compressor.rb
nanoc-4.8.4 test/filters/test_yui_compressor.rb
nanoc-4.8.3 test/filters/test_yui_compressor.rb
nanoc-4.8.2 test/filters/test_yui_compressor.rb
nanoc-4.8.1 test/filters/test_yui_compressor.rb
nanoc-4.8.0 test/filters/test_yui_compressor.rb
nanoc-4.7.14 test/filters/test_yui_compressor.rb
nanoc-4.7.13 test/filters/test_yui_compressor.rb
nanoc-4.7.12 test/filters/test_yui_compressor.rb
nanoc-4.7.11 test/filters/test_yui_compressor.rb
nanoc-4.7.10 test/filters/test_yui_compressor.rb