2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Adding parseInt to config.timeout (#3781)

* Adding parseInt to config.timeout

* Fixing test message
This commit is contained in:
Philipe Gouveia Paixão
2021-05-06 10:54:22 -03:00
committed by GitHub
parent 94fc4ea716
commit 199c8aab64
2 changed files with 74 additions and 2 deletions
+58
View File
@@ -29,6 +29,64 @@ describe('supports http with nodejs', function () {
}
});
it('should throw an error if the timeout property is not parsable as a number', function (done) {
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: { strangeTimeout: 250 }
}).then(function (res) {
success = true;
}).catch(function (err) {
error = err;
failure = true;
});
setTimeout(function () {
assert.equal(success, false, 'request should not succeed');
assert.equal(failure, true, 'request should fail');
assert.equal(error.code, 'ERR_PARSE_TIMEOUT');
assert.equal(error.message, 'error trying to parse `config.timeout` to int');
done();
}, 300);
});
});
it('should parse the timeout property', function (done) {
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 (err) {
error = err;
failure = true;
});
setTimeout(function () {
assert.equal(success, false, 'request should not succeed');
assert.equal(failure, true, 'request should fail');
assert.equal(error.code, 'ECONNABORTED');
assert.equal(error.message, 'timeout of 250ms exceeded');
done();
}, 300);
});
});
it('should respect the timeout property', function (done) {
server = http.createServer(function (req, res) {