made fakehttp provider async really async

This commit is contained in:
Fabian Vogelsteller 2015-09-14 12:05:01 +02:00
parent f18b532259
commit 82f215939d
1 changed files with 6 additions and 1 deletions

View File

@ -41,13 +41,18 @@ FakeHttpProvider.prototype.send = function (payload) {
};
FakeHttpProvider.prototype.sendAsync = function (payload, callback) {
assert.equal(utils.isArray(payload) || utils.isObject(payload), true);
assert.equal(utils.isFunction(callback), true);
if (this.validation) {
// imitate plain json object
this.validation(JSON.parse(JSON.stringify(payload)), callback);
}
callback(this.error, this.getResponse());
var response = this.getResponse();
var error = this.error;
setTimeout(function(){
callback(error, response);
});
};
FakeHttpProvider.prototype.injectResponse = function (response) {