Skip to content

Commit

Permalink
Test that the data-event listener is called with the render context a…
Browse files Browse the repository at this point in the history
…s its context and that the render context is also passed in as an argument

And fix up data-event-double-click
  • Loading branch information
Kamil Tusznio committed Nov 30, 2011
1 parent 00dd3dd commit 302f69a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/batman.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/batman.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3723,9 +3723,9 @@ Batman.DOM = {

node

doubleclick: (node, callback) ->
doubleclick: (node, callback, context) ->
# The actual DOM event is called `dblclick`
Batman.DOM.events.click node, callback, 'dblclick'
Batman.DOM.events.click node, callback, context, 'dblclick'

change: (node, callback) ->
eventNames = switch node.nodeName.toUpperCase()
Expand Down
18 changes: 11 additions & 7 deletions tests/batman/view/event_binding_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@ helpers = if typeof require is 'undefined' then window.viewHelpers else require

QUnit.module 'Batman.View event bindings'

asyncTest 'it should allow events to be bound and execute them in the context as specified on a multi key keypath', 2, ->
asyncTest 'it should allow events to be bound and execute them in the context as specified on a multi key keypath', 3, ->
context = Batman
foo: Batman
bar: Batman
doSomething: (node, renderContext) ->
equal @findKey('foo')[0], context.get('foo')
equal renderContext.findKey('foo')[0], context.get('foo')
QUnit.start()
doSomething: spy = createSpy()

source = '<button data-event-click="foo.bar.doSomething"></button>'
helpers.render source, context, (node) ->
helpers.triggerClick(node[0])
delay ->
equal spy.lastCallArguments[0], node[0]
equal spy.lastCallContext.findKey('foo')[0], context.get('foo')
equal spy.lastCallArguments[1].findKey('foo')[0], context.get('foo')

asyncTest 'it should allow events to be bound and execute them in the context as specified on terminal keypath', 1, ->
asyncTest 'it should allow events to be bound and execute them in the context as specified on terminal keypath', 3, ->
context = Batman
foo: 'bar'
doSomething: spy = createSpy()

source = '<button data-event-click="doSomething"></button>'
helpers.render source, context, (node) ->
helpers.triggerClick(node[0])
delay ->
equal spy.lastCallContext, context
equal spy.lastCallArguments[0], node[0]
equal spy.lastCallContext.findKey('foo')[0], 'bar'
equal spy.lastCallArguments[1].findKey('foo')[0], 'bar'

asyncTest 'it should allow click events to be bound', 2, ->
context =
Expand Down

0 comments on commit 302f69a

Please sign in to comment.