2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

Adding failing test for adapter errors

This commit is contained in:
Rubén Norte
2016-07-07 15:59:51 +02:00
parent 54f3a5dd93
commit 75f9b8c5fd
+29
View File
@@ -36,6 +36,35 @@ describe('requests', function () {
});
});
it('should reject on adapter errors', function (done) {
// disable jasmine.Ajax since we're hitting a non-existant server anyway
jasmine.Ajax.uninstall();
var resolveSpy = jasmine.createSpy('resolve');
var rejectSpy = jasmine.createSpy('reject');
var adapterError = new Error('adapter error');
var adapterThatFails = function () {
throw adapterError;
};
var finish = function () {
expect(resolveSpy).not.toHaveBeenCalled();
expect(rejectSpy).toHaveBeenCalled();
var reason = rejectSpy.calls.first().args[0];
expect(reason).toBe(adapterError);
expect(reason.config.method).toBe('get');
expect(reason.config.url).toBe('/foo');
done();
};
axios('/foo', {
adapter: adapterThatFails
}).then(resolveSpy, rejectSpy)
.then(finish, finish);
});
it('should reject on network errors', function (done) {
// disable jasmine.Ajax since we're hitting a non-existant server anyway
jasmine.Ajax.uninstall();