2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Improving logic for handling timeout in node

closes #124
This commit is contained in:
Matt Zabriskie
2016-01-22 16:27:54 -07:00
parent d31ebc4c50
commit 7a16f72895
2 changed files with 47 additions and 3 deletions
+28
View File
@@ -11,6 +11,34 @@ module.exports = {
callback();
},
testTimeout: function (test) {
server = http.createServer(function (req, res) {
setTimeout(function () {
res.end();
}, 1000);
}).listen(4444, function () {
var success = false, failure = false;
var error;
axios.get('http://localhost:4444/', {
timeout: 250
}).then(function (res) {
success = true;
}).catch(function (res) {
error = res;
failure = true;
});
setTimeout(function () {
test.equal(success, false, 'request should not succeed');
test.equal(failure, true, 'request should fail');
test.equal(error.code, 'ECONNABORTED');
test.equal(error.message, 'timeout of 250ms exceeded');
test.done();
}, 300);
});
},
testJSON: function (test) {
var data = {
firstName: 'Fred',