Skip to content

Commit ee02ea5

Browse files
committed
- Added Babel Transformer test to verify that the transformer accepts transformation options
- Fixed passing of transform options to the transformer
1 parent 9f97a06 commit ee02ea5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/react/jsx/babel_transformer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ def initialize(options)
1010
"Please use new Babel Transformer options :whitelist, :plugin instead.")
1111
end
1212

13-
DEFAULT_TRANSFORM_OPTIONS.merge(options)
13+
@transform_options = DEFAULT_TRANSFORM_OPTIONS.merge(options)
1414
end
1515

1616
def transform(code)
17-
Babel::Transpiler.transform(code)['code']
17+
Babel::Transpiler.transform(code, @transform_options)['code']
1818
end
1919
end
2020
end

test/react/jsx_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ class JSXTransformTest < ActionDispatch::IntegrationTest
6767
assert_equal "TRANSFORMED CODE!;\n", @response.body
6868
end
6969

70+
def test_babel_transformer_accepts_babel_transformation_options
71+
React::JSX.transform_options = {blacklist: ['spec.functionName', 'validation.react', "strict"]}
72+
get '/assets/example.js'
73+
assert_response :success
74+
75+
assert_not_includes @response.body, 'strict'
76+
end
77+
7078
end
7179

7280
class JSXTransformerTest < ActionDispatch::IntegrationTest

0 commit comments

Comments
 (0)