Sha256: 5ce3b1f5ad514e0b348910463cfa5c141f05272ffcb5286af68d66d1bfe87039
Contents?: true
Size: 963 Bytes
Versions: 2
Compression:
Stored size: 963 Bytes
Contents
require 'spec_helper' if opal? module React module Test class Utils def self.simulate(event, element) Simulate.new.click(element) end class Simulate include Native def initialize super(`React.addons.TestUtils.Simulate`) end def click(component_instance) `#{@native}['click']`.call(component_instance.dom_node, {}) end end end end end RSpec.describe React::Test::Utils do it 'simulates' do stub_const 'Foo', Class.new Foo.class_eval do include React::Component def hello @hello end def render @hello = 'hello' div { 'Click Me' }.on(:click) { |e| click(e) } end end instance = renderToDocument(Foo) expect_any_instance_of(Foo).to receive(:click) described_class.simulate(:click, instance) end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
hyper-react-0.10.0 | spec/react/test/utils_spec.rb |
reactrb-0.9.0 | spec/react/test/utils_spec.rb |