Sha256: 9b661da367751dc77ffa00bc6b9ee3ea85b8e518b8c8be2b776e749fe5208f14

Contents?: true

Size: 870 Bytes

Versions: 12

Compression:

Stored size: 870 Bytes

Contents

# encoding: utf-8

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

12 entries across 12 versions & 1 rubygems

Version Path
nanoc-3.7.3 test/filters/test_uglify_js.rb
nanoc-3.7.2 test/filters/test_uglify_js.rb
nanoc-3.7.1 test/filters/test_uglify_js.rb
nanoc-3.7.0 test/filters/test_uglify_js.rb
nanoc-3.6.11 test/filters/test_uglify_js.rb
nanoc-3.6.10 test/filters/test_uglify_js.rb
nanoc-3.6.9 test/filters/test_uglify_js.rb
nanoc-3.6.8 test/filters/test_uglify_js.rb
nanoc-3.6.7 test/filters/test_uglify_js.rb
nanoc-3.6.6 test/filters/test_uglify_js.rb
nanoc-3.6.5 test/filters/test_uglify_js.rb
nanoc-3.6.4 test/filters/test_uglify_js.rb