1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
# frozen_string_literal: true
require 'sprockets_test'
require 'minitest/autorun'
require 'sprockets/cache'
require 'sprockets/uglifier_compressor'
class TestUglifierCompressor < Minitest::Test
def setup
@env = Sprockets::Environment.new
@env.append_path File.expand_path("../fixtures", __FILE__)
end
def test_compress_javascript
input = {
environment: @env,
load_path: File.expand_path("../fixtures", __FILE__),
filename: File.expand_path("../fixtures/file.js", __FILE__),
content_type: 'application/javascript',
data: "function foo() {\n return true;\n}",
cache: Sprockets::Cache.new,
metadata: {
map: {
"version" => 3,
"file" => "test/file.js",
"mappings" => "AAAA",
"sources" => ["file.js"],
"names" => []
}
}
}
output = "function foo(){return!0}"
result = Sprockets::UglifierCompressor.call(input)
assert_equal output, result[:data]
end
def test_cache_key
assert Sprockets::UglifierCompressor.cache_key
end
end
|