fix comment stream jasmine - bind function after spy has been defined

This commit is contained in:
Florian Staudacher 2012-03-14 18:43:06 +01:00
parent b3868fc6dd
commit cd965e32fa
2 changed files with 9 additions and 4 deletions

View file

@ -14,7 +14,11 @@ app.views.CommentStream = app.views.Base.extend({
this.model.comments.bind('add', this.appendComment, this);
this.commentTemplate = options.commentTemplate;
this.model.bind("commentsExpanded", this.render, this)
this.setupBindings();
},
setupBindings: function() {
this.model.bind("commentsExpanded", this.render, this);
},
postRenderTemplate : function() {

View file

@ -6,9 +6,10 @@ describe("app.views.CommentStream", function(){
describe("binds", function() {
it("re-renders on a commentsExpanded trigger", function(){
spyOn(this.view, "render")
this.view.model.trigger("commentsExpanded")
expect(this.view.render).toHaveBeenCalled()
spyOn(this.view, "render");
this.view.setupBindings();
this.view.model.trigger("commentsExpanded");
expect(this.view.render).toHaveBeenCalled();
})
})