@@ -36,12 +36,6 @@ class JSXTransformTest < ActionDispatch::IntegrationTest
3636 reset_transformer
3737 end
3838
39- def reset_transformer
40- clear_sprockets_cache
41- React ::JSX . transformer_class = React ::JSX ::BabelTransformer
42- React ::JSX . transform_options = { }
43- end
44-
4539 test 'asset pipeline should transform JSX' do
4640 get '/assets/example.js'
4741 assert_response :success
@@ -73,68 +67,4 @@ def test_babel_transformer_accepts_babel_transformation_options
7367
7468 assert !@response . body . include? ( 'strict' )
7569 end
76-
77- end
78-
79- class JSXTransformerTest < ActionDispatch ::IntegrationTest
80-
81- setup do
82- reset_transformer
83- end
84-
85- teardown do
86- reset_transformer
87- end
88-
89- def reset_transformer
90- clear_sprockets_cache
91- React ::JSX . transformer_class = React ::JSX ::JSXTransformer
92- React ::JSX . transform_options = { }
93- end
94-
95- test 'can use dropped-in version of JSX transformer' do
96- hidden_path = Rails . root . join ( "vendor/assets/react/JSXTransformer__.js" )
97- replacing_path = Rails . root . join ( "vendor/assets/react/JSXTransformer.js" )
98-
99- FileUtils . cp hidden_path , replacing_path
100- get '/assets/example3.js'
101- FileUtils . rm replacing_path
102-
103- assert_response :success
104- assert_equal 'test_confirmation_token_jsx_transformed;' , @response . body
105- end
106-
107- test 'accepts harmony: true option' do
108- React ::JSX . transform_options = { harmony : true }
109- get '/assets/harmony_example.js'
110- assert_response :success
111- assert_match ( /generateGreeting:\s *function\( \) / , @response . body , "object literal methods" )
112- assert_match ( /React.__spread/ , @response . body , "spreading props" )
113- assert_match ( /Your greeting is: '" \+ insertedGreeting \+ "'/ , @response . body , "string interpolation" )
114- assert_match ( /active=\$ __0\. active/ , @response . body , "destructuring assignment" )
115- end
116-
117- test 'accepts strip_types: true option' do
118- React ::JSX . transform_options = { strip_types : true , harmony : true }
119- get '/assets/flow_types_example.js'
120- assert_response :success
121- assert_match ( /\( i\s *,\s *name\s *\) \s *\{ / , @response . body , "type annotations are removed" )
122- end
123-
124- test 'accepts asset_path: option' do
125- hidden_path = Rails . root . join ( "vendor/assets/react/JSXTransformer__.js" )
126- custom_path = Rails . root . join ( "vendor/assets/react/custom" )
127- replacing_path = custom_path . join ( "CustomTransformer.js" )
128-
129- React ::JSX . transform_options = { asset_path : "custom/CustomTransformer.js" }
130-
131- FileUtils . mkdir_p ( custom_path )
132- FileUtils . cp ( hidden_path , replacing_path )
133- get '/assets/example3.js'
134-
135- FileUtils . rm_rf custom_path
136- assert_response :success
137- assert_equal 'test_confirmation_token_jsx_transformed;' , @response . body
138- end
139-
14070end
0 commit comments