Created
October 23, 2014 22:56
-
-
Save michaeljacobdavis/675f66e9cf13af962975 to your computer and use it in GitHub Desktop.
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
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