Skip to content

Instantly share code, notes, and snippets.

@ruudud
Created March 12, 2013 14:41
Show Gist options
  • Save ruudud/5143435 to your computer and use it in GitHub Desktop.
Save ruudud/5143435 to your computer and use it in GitHub Desktop.
Buster/Sinon test click handler
var assert = buster.assertions.assert;
var refute = buster.assertions.refute;
var testCase = buster.testCase('my views', {
'spy reg': function () {
var View = Backbone.View.extend({
events: { 'click': 'myclick' },
myclick: function () {
console.log('orig handler click');
}
});
var myView = new View();
myView.myclick = sinon.spy();
myView.delegateEvents();
myView.$el.trigger('click');
assert.calledOnce(myView.myclick);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment