This repository was archived by the owner on Oct 19, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ if opal?
4
+
1
5
describe 'Refs callback' do
2
6
before do
3
7
stub_const 'Foo' , Class . new
@@ -15,36 +19,32 @@ def render
15
19
end
16
20
end
17
21
18
- stub_const 'MyBar' , nil
19
22
Foo . class_eval do
20
- def my_bar = ( bar )
21
- MyBar = bar
22
- end
23
+ attr_accessor :my_bar
23
24
24
25
def render
25
26
React . create_element ( Bar , ref : method ( :my_bar= ) . to_proc )
26
27
end
27
28
end
28
29
29
30
element = React . create_element ( Foo )
30
- React ::Test ::Utils . render_into_document ( element )
31
- expect ( MyBar ) . to be_a ( Bar )
31
+ instance = React ::Test ::Utils . render_into_document ( element )
32
+ expect ( instance . my_bar ) . to be_a ( Bar )
32
33
end
33
34
34
35
it "is invoked with the actual DOM node" do
35
- stub_const 'MyDiv' , nil
36
36
Foo . class_eval do
37
- def my_div = ( div )
38
- MyDiv = div
39
- end
37
+ attr_accessor :my_div
40
38
41
39
def render
42
40
React . create_element ( 'div' , ref : method ( :my_div= ) . to_proc )
43
41
end
44
42
end
45
43
46
44
element = React . create_element ( Foo )
47
- React ::Test ::Utils . render_into_document ( element )
48
- expect ( `#{ MyDiv } .nodeType` ) . to eq ( 1 )
45
+ instance = React ::Test ::Utils . render_into_document ( element )
46
+ expect ( `#{ instance . my_div } .nodeType` ) . to eq ( 1 )
49
47
end
50
48
end
49
+
50
+ end
You can’t perform that action at this time.
0 commit comments