@@ -18,50 +18,9 @@ class ViewHelperTest < ActionDispatch::IntegrationTest
18
18
include Capybara ::DSL
19
19
20
20
setup do
21
- @helper = ActionView ::Base . new . extend ( React ::Rails ::ViewHelper )
22
21
Capybara . current_driver = Capybara . javascript_driver
23
22
end
24
23
25
- test 'react_component accepts React props' do
26
- html = @helper . react_component ( 'Foo' , { bar : 'value' } )
27
- %w( data-react-class="Foo" data-react-props="{"bar":"value"}" ) . each do |segment |
28
- assert html . include? ( segment )
29
- end
30
- end
31
-
32
- test 'react_component accepts jbuilder-based strings as properties' do
33
- jbuilder_json = Jbuilder . new do |json |
34
- json . bar 'value'
35
- end . target!
36
-
37
- html = @helper . react_component ( 'Foo' , jbuilder_json )
38
- %w( data-react-class="Foo" data-react-props="{"bar":"value"}" ) . each do |segment |
39
- assert html . include? ( segment ) , "expected #{ html } to include #{ segment } "
40
- end
41
- end
42
-
43
- test 'react_component accepts string props with prerender: true' do
44
- html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : true )
45
- assert ( html . include? ( 'data-react-class="Todo"' ) , "it includes attrs for UJS" )
46
- assert ( html . include? ( '>render on the server</li>' ) , "it includes rendered HTML" )
47
- assert ( html . include? ( 'data-reactid' ) , "it includes React properties" )
48
- end
49
-
50
- test 'react_component passes :static to SprocketsRenderer' do
51
- html = @helper . react_component ( 'Todo' , { todo : 'render on the server' } . to_json , prerender : :static )
52
- assert ( html . include? ( '>render on the server</li>' ) , "it includes rendered HTML" )
53
- assert ( !html . include? ( 'data-reactid' ) , "it DOESNT INCLUDE React properties" )
54
- end
55
-
56
- test 'react_component accepts HTML options and HTML tag' do
57
- assert @helper . react_component ( 'Foo' , { } , :span ) . match ( /<span\s .*><\/ span>/ )
58
-
59
- html = @helper . react_component ( 'Foo' , { } , { :class => 'test' , :tag => :span , :data => { :foo => 1 } } )
60
- assert html . match ( /<span\s .*><\/ span>/ )
61
- assert html . include? ( 'class="test"' )
62
- assert html . include? ( 'data-foo="1"' )
63
- end
64
-
65
24
test 'ujs object present on the global React object and has our methods' do
66
25
visit '/pages/1'
67
26
assert page . has_content? ( 'Hello Bob' )
0 commit comments