I'm trying to test a code that waits for a Promise before calling http:
Code:
function foo() {
return Parse.Promise.as(1).then(function(one) {
return $http.get('/bar');
});
}
Test:
describe('foo', function() {
it('gets', function(done) {
$httpBackend.expect('GET', '/bar').respond(200);
foo().then(function(res) {
expect(res.status).to.be.equal(200);
done();
});
$httpBackend.flush();
});
});
Error:
1) gets
foo
No pending request to flush !
My guess is that beacuse Parse.Promise
delays the promise resolution, and the http request wasn't made when the $httpBackend.flush
is called.
Is there any workaround for this?
Aucun commentaire:
Enregistrer un commentaire