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

Commit 63de86c

Browse files
committed
Migrate react_spec to React::Test::Utils.render_into_document
1 parent bce5448 commit 63de86c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

spec/react/react_spec.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,32 @@
5353
before do
5454
stub_const 'Foo', Class.new
5555
Foo.class_eval do
56+
def initialize(native)
57+
@native = native
58+
end
59+
5660
def render
5761
React.create_element("div") { "lorem" }
5862
end
63+
64+
def props
65+
Hash.new(`#@native.props`)
66+
end
5967
end
6068
end
6169

6270
it "should render element with only one children correctly" do
6371
element = React.create_element(Foo) { React.create_element('span') }
64-
instance = renderElementToDocument(element)
65-
expect(instance.props.children).not_to be_a(Array)
66-
expect(instance.props.children.type).to eq("span")
72+
instance = React::Test::Utils.render_into_document(element)
73+
expect(instance.props[:children]).not_to be_a(Array)
74+
expect(instance.props[:children][:type]).to eq("span")
6775
end
6876

6977
it "should render element with more than one children correctly" do
7078
element = React.create_element(Foo) { [React.create_element('span'), React.create_element('span')] }
71-
instance = renderElementToDocument(element)
72-
expect(instance.props.children).to be_a(Array)
73-
expect(instance.props.children.length).to eq(2)
79+
instance = React::Test::Utils.render_into_document(element)
80+
expect(instance.props[:children]).to be_a(Array)
81+
expect(instance.props[:children].length).to eq(2)
7482
end
7583

7684
it "should create a valid element provided class defined `render`" do

0 commit comments

Comments
 (0)