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

Commit 585b6ac

Browse files
committed
renderToDocument helper now use React::Test::Utils
1 parent 8847d79 commit 585b6ac

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

spec/react/component_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ def render
282282
end
283283
end
284284

285-
element = renderToDocument(Foo)
286-
expect(element.state.foo).to be('bar')
285+
instance = renderToDocument(Foo)
286+
expect(instance.state[:foo]).to be('bar')
287287
end
288288

289289
it 'supports original `replaceState` as `set_state!` method' do
@@ -295,8 +295,8 @@ def render
295295
end
296296

297297
element = renderToDocument(Foo)
298-
expect(element.state.foo).to be_nil
299-
expect(element.state.bar).to eq('lorem')
298+
expect(element.state[:foo]).to be_nil
299+
expect(element.state[:bar]).to eq('lorem')
300300
end
301301

302302
it 'supports original `state` method' do
@@ -389,9 +389,9 @@ def render
389389
end
390390
end
391391

392-
element = renderToDocument(Foo, {foo: 10})
393-
element.set_props!(bar: 20)
394-
expect(element.getDOMNode.innerHTML).to eq('null')
392+
instance = renderToDocument(Foo, {foo: 10})
393+
instance.set_props!(bar: 20)
394+
expect(`#{instance.dom_node}.innerHTML`).to eq('null')
395395
end
396396
end
397397

@@ -632,8 +632,8 @@ def render
632632
end
633633
end
634634

635-
element = renderToDocument(Foo)
636-
expect(element.refs.field).not_to be_nil
635+
instance = renderToDocument(Foo)
636+
expect(instance.refs[:field]).not_to be_nil
637637
end
638638

639639
it 'accesses refs through `refs` method' do
@@ -650,10 +650,10 @@ def render
650650
expect(instance.refs[:field].value).to eq('some_stuff')
651651
end
652652

653-
it "allows access the actual DOM node" do
653+
it "allows access the actual DOM node", v13_exclude: true do
654654
Foo.class_eval do
655655
after_mount do
656-
dom = refs[:my_div].dom_node
656+
dom = refs[:my_div].to_n
657657
`dom.innerHTML = 'Modified'`
658658
end
659659

spec/support/react/spec_helpers.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ module SpecHelpers
55

66
def renderToDocument(type, options = {})
77
element = React.create_element(type, options)
8-
instance = Native(`ReactTestUtils.renderIntoDocument(#{element.to_n})`)
9-
instance.class.include(React::Component::API)
10-
instance
8+
React::Test::Utils.render_into_document(element)
119
end
1210

1311
def isElementOfType(element, type)

0 commit comments

Comments
 (0)