Sha256: d0d3ec1b4e2c4db070b7f86762cadfd9ed847dfc2027a3299e0bfc8f24c18f51

Contents?: true

Size: 886 Bytes

Versions: 17

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

require 'helper'

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

17 entries across 17 versions & 1 rubygems

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