File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 22 < li > <%= link_to 'Alice' , page_path ( :id => 0 ) %> </ li >
33 < li > <%= link_to 'Bob' , page_path ( :id => 1 ) %> </ li >
44</ ul >
5+
56< div id ='test-component '>
67 <%= react_component 'HelloMessage' , :name => @name %>
78</ 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
8787 assert page . has_content? ( 'Hello Bob' )
8888 end
8989
90- test 'react_ujs can unount at node ' do
90+ test 'react_ujs can unmount/mount using a selector reference ' do
9191 visit '/pages/1'
9292 assert page . has_content? ( 'Hello Bob' )
9393
94- page . click_link ' Unmount at #test-component'
94+ page . click_link " Unmount at selector #test-component"
9595 assert page . has_no_content? ( 'Hello Bob' )
9696
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"
98109 assert page . has_content? ( 'Hello Bob' )
99110 end
100111
You can’t perform that action at this time.
0 commit comments