Skip to content

Commit 4e7d604

Browse files
authored
Merge pull request #961 from huacnlee/fix/assert-react-component-with-multiple-case
Fix assert_react_component test helper for multiple components page
2 parents c86cfa1 + 855b528 commit 4e7d604

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/react/rails/test_helper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ module TestHelper
99
# assert_equal "Hello world", props[:message]
1010
# end
1111
def assert_react_component(name)
12-
assert_select "div[data-react-class]" do |dom|
13-
assert_select "[data-react-class=?]", name
14-
12+
assert_select "div[data-react-class=?]", name do |dom|
1513
if block_given?
1614
props = JSON.parse(dom.attr("data-react-props"))
1715
props.deep_transform_keys! { |key| key.to_s.underscore }

test/react/rails/test_helper_test.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ class TestHelperTest < ActionDispatch::IntegrationTest
1313
assert_select "[id=?]", "component"
1414
assert_select "[class=?]", "greeting-message"
1515
end
16+
assert_react_component "Todo" do |props|
17+
assert_equal "Another Component", props[:todo]
18+
end
1619
end
1720
end

0 commit comments

Comments
 (0)