forked from rails/sprockets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_coffee_script_processor.rb
34 lines (31 loc) · 1.09 KB
/
test_coffee_script_processor.rb
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
# frozen_string_literal: true
require 'sprockets_test'
require 'minitest/autorun'
require 'sprockets/cache'
require 'sprockets/coffee_script_processor'
require 'sprockets/source_map_utils'
class TestCoffeeScriptProcessor < MiniTest::Test
def setup
@env = Sprockets::Environment.new
@env.append_path File.expand_path("../fixtures", __FILE__)
end
def test_compile_coffee_script_template_to_js
input = {
load_path: File.expand_path("../fixtures", __FILE__),
filename: File.expand_path("../fixtures/squared.coffee", __FILE__),
content_type: 'application/javascript',
environment: @env,
data: "square = (n) -> n * n",
name: 'squared',
cache: Sprockets::Cache.new,
metadata: { mapping: [] }
}
result = Sprockets::CoffeeScriptProcessor.call(input)
assert result[:data].match(/var square/)
assert_equal 13, Sprockets::SourceMapUtils.decode_source_map(result[:map])[:mappings].size
assert_equal ["squared.source.coffee"], result[:map]["sources"]
end
def test_cache_key
assert Sprockets::CoffeeScriptProcessor.cache_key
end
end