Sha256: c5d28752e9c8014a464dd0e5f58f585fbe43eaa2dbb921493aa438f9f759fa9d
Contents?: true
Size: 1.06 KB
Versions: 8
Compression:
Stored size: 1.06 KB
Contents
require 'spec_helper' if opal? describe 'Refs callback' do before do stub_const 'Foo', Class.new Foo.class_eval do include React::Component end end it "is invoked with the actual Ruby instance" do stub_const 'Bar', Class.new Bar.class_eval do include React::Component def render React.create_element('div') end end Foo.class_eval do def my_bar=(bar) $bar = bar end def render React.create_element(Bar, ref: method(:my_bar=).to_proc) end end element = React.create_element(Foo) React::Test::Utils.render_into_document(element) expect($bar).to be_a(Bar) $bar = nil end it "is invoked with the actual DOM node" do Foo.class_eval do def my_div=(div) $div = div end def render React.create_element('div', ref: method(:my_div=).to_proc) end end element = React.create_element(Foo) React::Test::Utils.render_into_document(element) expect(`#{$div}.nodeType`).to eq(1) $div = nil end end end
Version data entries
8 entries across 8 versions & 1 rubygems