Created
September 11, 2012 23:38
-
-
Save p-baleine/3703041 to your computer and use it in GitHub Desktop.
testing listener of Backbone event
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
describe('when add event is fired on Todos collection', function() { | |
before(function() { | |
var init = this.TodoList.prototype.initialize; | |
// spying event related method | |
this.TodoList.prototype.initialize = function() { | |
sinon.spy(this, 'renderOne'); | |
init.apply(this, arguments); | |
}; | |
this.todoList = new this.TodoList({ el: '#main' }); | |
this.added = new Backbone.Model({ content: 'piyo' }); | |
this.todoList.collection.add(this.added); | |
}); | |
after(function() { | |
this.todoList.renderOne.restore(); | |
}); | |
it ('should render new TodoItem view', function() { | |
this.todoList.renderOne.calledOnce.should.be.ok; | |
this.todoList.renderOne.args[0][0].get('content').should.eql('piyo'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment