Created
November 10, 2011 18:18
-
-
Save ppcano/1355632 to your computer and use it in GitHub Desktop.
Testing sproutcore-touch passing through child elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('sproutcore'); | |
require('sproutcore-touch'); | |
var set = SC.set, get = SC.get; | |
var tapEndWasCalled = true; | |
module("Touching handlebars tests", { | |
setup: function() { | |
console.group(' - Setup for new test'); | |
tapEndWasCalled = false | |
}, | |
teardown: function() { | |
console.groupEnd(); | |
} | |
}); | |
test("View do not respond when child has not ", function() { | |
var application = SC.Application.create(); | |
var view = SC.CollectionView.create({ | |
content: [1,2,3,4,6], | |
itemViewClass: SC.View.extend({ | |
tapOptions: { | |
numberOfRequiredTouches: 1 | |
}, | |
tapEnd: function(recognizer) { | |
tapEndWasCalled = true; | |
}, | |
template: SC.Handlebars.compile('<span> {{content}} </span>') | |
}) | |
}); | |
SC.run(function(){ | |
view.append(); | |
}); | |
// look for the span element | |
var id =view.$().children()[0].id; | |
var element = view.$('#'+id +' span'); | |
var touchEvent; | |
touchEvent = new jQuery.Event(); | |
touchEvent.type='touchstart'; | |
touchEvent['originalEvent'] = { | |
targetTouches: [{ | |
identifier: 0, | |
pageX: 0, | |
pageY: 10 | |
}] | |
}; | |
element.trigger(touchEvent); | |
touchEvent = new jQuery.Event(); | |
touchEvent.type='touchend'; | |
touchEvent['originalEvent'] = { | |
changedTouches: [{ | |
identifier: 0, | |
pageX: 0, | |
pageY: 10 | |
}] | |
}; | |
element.trigger(touchEvent); | |
ok(tapEndWasCalled, 'tap end should have been called'); | |
view.destroy(); | |
application.destroy(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment