File tree 2 files changed +21
-5
lines changed
2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 2
2
< li > <%= link_to 'Alice' , page_path ( :id => 0 ) %> </ li >
3
3
< li > <%= link_to 'Bob' , page_path ( :id => 1 ) %> </ li >
4
4
</ ul >
5
+
5
6
< div id ='test-component '>
6
7
<%= react_component 'HelloMessage' , :name => @name %>
7
8
</ div >
8
- < a href ='# ' onClick ="ReactRailsUJS.unmountComponents('#test-component') "> Unmount at #test-component</ a >
9
- < a href ='# ' onClick ="ReactRailsUJS.mountComponents('#test-component') "> Mount at #test-component</ a >
9
+
10
+ < a href ='# ' onClick ="ReactRailsUJS.unmountComponents('#test-component') "> Unmount at selector #test-component</ a >
11
+ < a href ='# ' onClick ="ReactRailsUJS.mountComponents('#test-component') "> Mount at selector #test-component</ a >
12
+
13
+ < a href ='# ' onClick ="ReactRailsUJS.unmountComponents(document.querySelector('#test-component')) "> Unmount at node #test-component</ a >
14
+ < a href ='# ' onClick ="ReactRailsUJS.mountComponents(document.querySelector('#test-component')) "> Mount at node #test-component</ a >
Original file line number Diff line number Diff line change @@ -87,14 +87,25 @@ class ViewHelperTest < ActionDispatch::IntegrationTest
87
87
assert page . has_content? ( 'Hello Bob' )
88
88
end
89
89
90
- test 'react_ujs can unount at node ' do
90
+ test 'react_ujs can unmount/mount using a selector reference ' do
91
91
visit '/pages/1'
92
92
assert page . has_content? ( 'Hello Bob' )
93
93
94
- page . click_link ' Unmount at #test-component'
94
+ page . click_link " Unmount at selector #test-component"
95
95
assert page . has_no_content? ( 'Hello Bob' )
96
96
97
- page . click_link 'Mount at #test-component'
97
+ page . click_link "Mount at selector #test-component"
98
+ assert page . has_content? ( 'Hello Bob' )
99
+ end
100
+
101
+ test 'react_ujs can unmount/mount using a dom node context' do
102
+ visit '/pages/1'
103
+ assert page . has_content? ( 'Hello Bob' )
104
+
105
+ page . click_link "Unmount at node #test-component"
106
+ assert page . has_no_content? ( 'Hello Bob' )
107
+
108
+ page . click_link "Mount at node #test-component"
98
109
assert page . has_content? ( 'Hello Bob' )
99
110
end
100
111
You can’t perform that action at this time.
0 commit comments