Sha256: b2007d2fd0be3e2e3dddb6dede10aeb6ea6e8b811a12bcff3d61334f9ce8859c
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
describe Event do before do @div = Document.parse <<-HTML <div id="on-spec"> <div id="foo"> <div id="bar"></div> </div> <div id="baz"></div> </div> HTML @div.append_to_body end after do @div.remove end it '#current_target returns the current element in the bubbling' do foo = Document['#foo'] bar = Document['#bar'] result = [] foo.on(:click) { |e| result << e.current_target.id } bar.on(:click) { |e| result << e.current_target.id } foo.trigger(:click) result.should == ['foo'] result = [] bar.trigger(:click) result.should == ['bar', 'foo'] end it '#type returns the type of event' do type = nil foo = Document['#foo'] foo.on(:click) { |e| type = e.type } foo.on(:mousedown) { |e| type = e.type } foo.on(:opal_random) { |e| type = e.type } foo.trigger(:click) type.should == :click foo.trigger(:mousedown) type.should == :mousedown foo.trigger(:opal_random) type.should == :opal_random end it '#target returns a JQuery wrapper around the element that triggered the event' do foo = Document['#foo'] bar = Document['#bar'] target = nil foo.on(:click) { |e| target = e.target.id } foo.trigger(:click) target.should == 'foo' bar.trigger(:click) target.should == 'bar' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-jquery-0.0.1 | spec/event_spec.rb |