Skip to content

Instantly share code, notes, and snippets.

@michaeljacobdavis
Created October 23, 2014 22:56
Show Gist options
  • Save michaeljacobdavis/675f66e9cf13af962975 to your computer and use it in GitHub Desktop.
Save michaeljacobdavis/675f66e9cf13af962975 to your computer and use it in GitHub Desktop.
it('waits for delete to return before saving', function(done){
// Given
var options = {
model: new Backbone.Model({
modules: new Backbone.Collection([
new Model(),
new Model()
])
}),
success: function(){}
};
Model.prototype.save.restore();
var saveSpy = sandbox.stub(Model.prototype, 'save', function(props, options){
options.success(this);
});
syncher.del.restore();
var delSpy = sandbox.stub(syncher, 'del', function(svc, data, options){
if(svc.indexOf('variationModules') !== -1){
setTimeout(function(){
// Then
expect(delSpy).to.have.been.called;
expect(saveSpy).to.have.not.been.called;
options.success({ payload: { } });
// Then
done();
}, 1);
}
options.success({ payload: { } });
});
// When
syncher.add(null, options);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment