Sha256: c211d7d2f4242b97a4459eb72b8f1d64b21ffac47bac89822cb5f420599ed409

Contents?: true

Size: 837 Bytes

Versions: 39

Compression:

Stored size: 837 Bytes

Contents

class Nanoc::Filters::UglifyJSTest < Nanoc::TestCase
  def test_filter
    if_have 'uglifier' do
      # Create filter
      filter = ::Nanoc::Filters::UglifyJS.new

      # Run filter
      input = 'foo = 1; (function(bar) { if (true) alert(bar); })(foo)'
      result = filter.setup_and_run(input)
      assert_match(/foo=1,function\((.)\)\{alert\(\1\)\}\(foo\);/, result)
    end
  end

  def test_filter_with_options
    if_have 'uglifier' do
      filter = ::Nanoc::Filters::UglifyJS.new
      input = "if(donkey) alert('It is a donkey!');"

      result = filter.setup_and_run(input, output: { beautify: false })
      assert_equal 'donkey&&alert("It is a donkey!");', result

      result = filter.setup_and_run(input, output: { beautify: true })
      assert_equal 'donkey && alert("It is a donkey!");', result
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
nanoc-4.4.4 test/filters/test_uglify_js.rb
nanoc-4.4.3 test/filters/test_uglify_js.rb
nanoc-4.4.2 test/filters/test_uglify_js.rb
nanoc-4.4.1 test/filters/test_uglify_js.rb
nanoc-4.4.0 test/filters/test_uglify_js.rb
nanoc-4.3.8 test/filters/test_uglify_js.rb
nanoc-4.3.7 test/filters/test_uglify_js.rb
nanoc-4.3.6 test/filters/test_uglify_js.rb
nanoc-4.3.5 test/filters/test_uglify_js.rb
nanoc-4.3.4 test/filters/test_uglify_js.rb
nanoc-4.3.3 test/filters/test_uglify_js.rb
nanoc-4.3.2 test/filters/test_uglify_js.rb
nanoc-4.3.1 test/filters/test_uglify_js.rb
nanoc-4.3.0 test/filters/test_uglify_js.rb
nanoc-4.2.4 test/filters/test_uglify_js.rb
nanoc-4.2.3 test/filters/test_uglify_js.rb
nanoc-4.2.2 test/filters/test_uglify_js.rb
nanoc-4.2.1 test/filters/test_uglify_js.rb
nanoc-4.2.0 test/filters/test_uglify_js.rb
nanoc-4.1.6 test/filters/test_uglify_js.rb