@@ -12,7 +12,7 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
1212 end
1313
1414 test '#react_component accepts React props' do
15- html = @helper . react_component ( 'Foo' , { bar : 'value' } )
15+ html = @helper . react_component ( 'Foo' , { bar : 'value' } )
1616 expected_props = %w( data-react-class="Foo" data-react-props="{"bar":"value"}" )
1717 expected_props . each do |segment |
1818 assert html . include? ( segment )
@@ -22,7 +22,7 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
2222 test '#react_component accepts React props with camelize_props' do
2323 React ::Rails ::ComponentMount . camelize_props_switch = true
2424 helper = React ::Rails ::ComponentMount . new
25- html = helper . react_component ( 'Foo' , { foo_bar : 'value' } )
25+ html = helper . react_component ( 'Foo' , { foo_bar : 'value' } )
2626 expected_props = %w( data-react-class="Foo" data-react-props="{"fooBar":"value"}" )
2727 expected_props . each do |segment |
2828 assert html . include? ( segment )
@@ -32,15 +32,15 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
3232 test '#react_component allows camelize_props to be passed in as an option' do
3333 React ::Rails ::ComponentMount . camelize_props_switch = false
3434 helper = React ::Rails ::ComponentMount . new
35- html = helper . react_component ( 'Foo' , { foo_bar : 'value' } , camelize_props : true )
35+ html = helper . react_component ( 'Foo' , { foo_bar : 'value' } , camelize_props : true )
3636 expected_props = %w( data-react-class="Foo" data-react-props="{"fooBar":"value"}" )
3737 expected_props . each do |segment |
3838 assert html . include? ( segment )
3939 end
4040
4141 React ::Rails ::ComponentMount . camelize_props_switch = true
4242 helper = React ::Rails ::ComponentMount . new
43- html = helper . react_component ( 'Foo' , { foo_bar : 'value' } , camelize_props : false )
43+ html = helper . react_component ( 'Foo' , { foo_bar : 'value' } , camelize_props : false )
4444 expected_props = %w( data-react-class="Foo" data-react-props="{"foo_bar":"value"}" )
4545 expected_props . each do |segment |
4646 assert html . include? ( segment )
@@ -50,7 +50,7 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
5050 test '#react_component accepts React props with camelize_props containing nested arrays' do
5151 React ::Rails ::ComponentMount . camelize_props_switch = true
5252 helper = React ::Rails ::ComponentMount . new
53- html = helper . react_component ( 'Foo' , { foo_bar : [ { user_name : 'Ryan' } , { user_name : 'Matt' } ] , bar_foo : 1 } )
53+ html = helper . react_component ( 'Foo' , { foo_bar : [ { user_name : 'Ryan' } , { user_name : 'Matt' } ] , bar_foo : 1 } )
5454 expected_props = %w( data-react-class="Foo" data-react-props="{"fooBar":[{"userName":"Ryan"},{"userName":"Matt"}],"barFoo":1}" )
5555 expected_props . each do |segment |
5656 assert html . include? ( segment )
@@ -70,27 +70,27 @@ class ComponentMountTest < ActionDispatch::IntegrationTest
7070 end
7171
7272 test '#react_component accepts string props with prerender: true' do
73- html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : true )
73+ html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : true )
7474 assert ( html . include? ( 'data-react-class="Todo"' ) , "it includes attrs for UJS" )
7575 assert ( html . include? ( '>render on the server</li>' ) , "it includes rendered HTML" )
7676 assert ( html . include? ( 'data-reactid' ) , "it includes React properties" )
7777 end
7878
7979 test '#react_component passes :static to BundleRenderer' do
80- html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : :static )
80+ html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : :static )
8181 assert ( html . include? ( '>render on the server</li>' ) , "it includes rendered HTML" )
8282 assert ( !html . include? ( 'data-reactid' ) , "it DOESNT INCLUDE React properties" )
8383 end
8484
8585 test '#react_component does not include HTML properties with a static render' do
86- html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : :static )
86+ html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : :static )
8787 assert_equal ( '<div><li>render on the server</li></div>' , html )
8888 end
8989
9090 test '#react_component accepts HTML options and HTML tag' do
9191 assert @helper . react_component ( 'Foo' , { } , :span ) . match ( /<span\s .*><\/ span>/ )
9292
93- html = @helper . react_component ( 'Foo' , { } , { class : 'test' , tag : :span , data : { foo : 1 } } )
93+ html = @helper . react_component ( 'Foo' , { } , { class : 'test' , tag : :span , data : { foo : 1 } } )
9494 assert html . match ( /<span\s .*><\/ span>/ )
9595 assert html . include? ( 'class="test"' )
9696 assert html . include? ( 'data-foo="1"' )
@@ -110,7 +110,7 @@ def self.react_rails_prerenderer
110110
111111 test "it uses the controller's react_rails_prerenderer, if available" do
112112 @helper . setup ( DummyController )
113- rendered_component = @helper . react_component ( 'Foo' , { "ok" => true } , prerender : :static )
113+ rendered_component = @helper . react_component ( 'Foo' , { "ok" => true } , prerender : :static )
114114 assert_equal %|<div>rendered Foo with {"ok":true}</div>| , rendered_component
115115 end
116116 end
0 commit comments