persist unsaved comment value after expanding comments
This commit is contained in:
Dan Hansen 2012-05-24 19:08:43 -07:00
parent f19f6110b1
commit d334097ee2
2 changed files with 22 additions and 2 deletions

View file

@ -61,16 +61,20 @@ app.views.CommentStream = app.views.Base.extend({
expandComments: function(evt){
if(evt){ evt.preventDefault(); }
var self = this;
var localCommentValue = this.$("textarea").val(),
self = this;
this.model.comments.fetch({
success : function(resp){
self.model.set({
comments : resp.models,
all_comments_loaded : true
})
self.model.trigger("commentsExpanded", self)
self.$("textarea").val(localCommentValue).focus()
}
});
}
});

View file

@ -38,4 +38,20 @@ describe("app.views.CommentStream", function(){
expect(comment.set).toHaveBeenCalled()
})
})
describe("expandComments", function() {
it("refills the comment textbox on success", function() {
jasmine.Ajax.useMock();
this.view.render();
this.view.$("textarea").val("great post!");
this.view.expandComments();
mostRecentAjaxRequest().response({ comments : [] });
expect(this.view.$("textarea").val()).toEqual("great post!");
})
})
})