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

Adding tests for interceptors on custom instances

This commit is contained in:
Matt Zabriskie
2015-12-11 13:52:23 -07:00
parent 4ffeba3cde
commit f9c46c5c1d
+34
View File
@@ -38,4 +38,38 @@ describe('instance', function () {
done();
}, 0);
});
it('should have interceptors on the instance', function (done) {
axios.interceptors.request.use(function (config) {
config.foo = true;
return config;
});
var instance = axios.create();
instance.interceptors.request.use(function (config) {
config.bar = true;
return config;
});
var response;
instance.request({
url: '/foo'
}).then(function (res) {
response = res;
});
setTimeout(function () {
request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
status: 200
});
setTimeout(function () {
expect(response.config.foo).toEqual(undefined);
expect(response.config.bar).toEqual(true);
done();
});
}, 0);
});
});