Sha256: 3b0754274f1ba70870586435ebca878a662a723ce0878ae750da1ce67a7a7da2

Contents?: true

Size: 883 Bytes

Versions: 1

Compression:

Stored size: 883 Bytes

Contents

class Nanoc::Filters::UglifyJSTest < Nanoc::TestCase
  def test_filter
    skip_v8_on_ruby24

    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
    skip_v8_on_ruby24

    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

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-4.4.5 test/filters/test_uglify_js.rb