Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 708720d

Browse files
committed
Migrate component_spec to React::Test::Utils.render_into_document
1 parent 63de86c commit 708720d

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

spec/react/component_spec.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def render
595595

596596
expect { |b|
597597
element = React.create_element(Foo).on(:foo_submit, &b)
598-
renderElementToDocument(element)
598+
React::Test::Utils.render_into_document(element)
599599
}.to yield_with_args('bar')
600600
end
601601

@@ -614,7 +614,7 @@ def render
614614

615615
expect { |b|
616616
element = React.create_element(Foo).on(:foo_invoked, &b)
617-
renderElementToDocument(element)
617+
React::Test::Utils.render_into_document(element)
618618
}.to yield_with_args([1,2,3], 'bar')
619619
end
620620
end
@@ -845,10 +845,6 @@ def render
845845
stub_const 'Foo', Class.new
846846
Foo.class_eval do
847847
include React::Component
848-
export_state :the_children
849-
before_mount do
850-
the_children! children
851-
end
852848
def render
853849
React.create_element('div') { 'lorem' }
854850
end
@@ -859,9 +855,9 @@ def render
859855
ele = React.create_element(Foo) {
860856
[React.create_element('a'), React.create_element('li')]
861857
}
862-
renderElementToDocument(ele)
858+
instance = React::Test::Utils.render_into_document(ele)
863859

864-
children = Foo.the_children
860+
children = instance.children
865861

866862
expect(children).to be_a(React::Children)
867863
expect(children.count).to eq(2)
@@ -870,8 +866,8 @@ def render
870866

871867
it 'returns an empty Enumerator if there are no children' do
872868
ele = React.create_element(Foo)
873-
renderElementToDocument(ele)
874-
nodes = Foo.the_children.each
869+
instance = React::Test::Utils.render_into_document(ele)
870+
nodes = instance.children.each
875871
expect(nodes.size).to eq(0)
876872
expect(nodes.count).to eq(0)
877873
end

0 commit comments

Comments
 (0)