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

Commit 9caec7b

Browse files
committed
almost there
1 parent b654ffe commit 9caec7b

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

spec/react/opal_jquery_extensions_spec.rb

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@
22

33
describe 'opal-jquery extensions', js: true do
44
describe 'Element' do
5-
xit 'will reuse the wrapper componet class for the same Element' do
6-
# TODO how come a def component_will_unmount will not be received
7-
stub_const 'Foo', Class.new(React::Component::Base)
8-
Foo.class_eval do
9-
param :name
10-
def render
11-
"hello #{params.name}"
12-
end
13-
14-
def component_will_unmount
5+
xit 'will reuse the wrapper component class for the same Element' do
6+
evaluate_ruby do
7+
class Foo < React::Component::Base
8+
param :name
9+
def render
10+
"hello #{params.name}"
11+
end
1512

13+
def self.rec_cnt
14+
@@rec_cnt ||= 0
15+
end
16+
before_unmount do
17+
@@rec_cnt ||= 0
18+
@@rec_cnt += 1
19+
end
1620
end
1721
end
18-
19-
expect_any_instance_of(Foo).to_not receive(:component_will_unmount)
20-
21-
test_div = Element.new(:div)
22-
test_div.render { Foo(name: 'fred') }
23-
test_div.render { Foo(name: 'freddy') }
24-
expect(Element[test_div].find('span').html).to eq('hello freddy')
22+
expect_evaluate_ruby do
23+
test_div = Element.new(:div)
24+
test_div.render { Foo(name: 'fred') }
25+
test_div.render { Foo(name: 'freddy') }
26+
[ Element[test_div].find('span').html, Foo.rec_cnt]
27+
end.to eq(['hello freddy', 0])
2528
end
2629

2730
it 'renders a top level component using render with a block' do

0 commit comments

Comments
 (0)