mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user