Skip to content

Commit

Permalink
created tests to verify that addEventListener is not capturing elemen…
Browse files Browse the repository at this point in the history
…ts, that only have delegated events assigned philc#1404
  • Loading branch information
Maxim Baz committed Jan 3, 2015
1 parent 4aed55b commit e22fa09
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions tests/dom_tests/dom_tests.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,39 @@ createGeneralHintTests = (isFilteredMode) ->
stub settings.values, "linkHintCharacters", "ab"
stub settings.values, "linkHintNumbers", "0123456789"

clickableSpan = "<span class='clickable'>Click me</span>" + "<span>Don't click me</span>"
clickableSpan = "
<div id='container'>
<span class='clickable'>Click me</span>
<span>Don't click me</span>
</div>"
document.getElementById("test-div").innerHTML = clickableSpan

$(document).on 'click', '.clickable', ( -> )

LinkHints.init()
LinkHints.activateMode()

tearDown ->
LinkHints.deactivateMode()
document.getElementById("test-div").innerHTML = ""

should "create links for elements, that have delegated event handler assigned", ->
should "create link hints for elements, being listened through document element", ->
$(document).on 'click', '.clickable', ( -> )

LinkHints.activateMode()
assert.equal 1, getHintMarkers().length
LinkHints.deactivateMode()

should "create link hints for elements, being listened through parent DOM element", ->
$("#container").on 'click', '.clickable', ( -> )

LinkHints.activateMode()
assert.equal 1, getHintMarkers().length
LinkHints.deactivateMode()

should "create a link hint for parent if it has normal event listener assigned", ->
$("#container").on 'click', ( -> )
$("#container").on 'click', '.clickable', ( -> )

LinkHints.activateMode()
assert.equal 2, getHintMarkers().length
LinkHints.deactivateMode()


createGeneralHintTests false
Expand Down

0 comments on commit e22fa09

Please sign in to comment.