Skip to content

Commit

Permalink
chore: always use camelCase for var names
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Stewmon committed Jul 13, 2018
1 parent 98b5664 commit 918799f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions source/normalize-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const isRetryOnNetworkErrorAllowed = require('./is-retry-on-network-error-allowe
const urlToOptions = require('./url-to-options');
const isFormData = require('./is-form-data');

const RETRY_AFTER_STATUS_CODES = new Set([413, 429, 503]);
const retryAfterStatusCodes = new Set([413, 429, 503]);

module.exports = (url, options, defaults) => {
if (Reflect.has(options, 'url') || (is.object(url) && Reflect.has(url, 'url'))) {
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = (url, options, defaults) => {
return 0;
}

if (Reflect.has(error, 'headers') && Reflect.has(error.headers, 'retry-after') && RETRY_AFTER_STATUS_CODES.has(error.statusCode)) {
if (Reflect.has(error, 'headers') && Reflect.has(error.headers, 'retry-after') && retryAfterStatusCodes.has(error.statusCode)) {
let after = Number(error.headers['retry-after']);
if (is.number(after)) {
after *= 1000;
Expand Down
22 changes: 11 additions & 11 deletions test/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ let knocks = 0;
let fifth = 0;
let lastTried413access = Date.now();

const RETRY_AFTER_ON_413 = 2;
const CONNECT_TIMEOUT = 500;
const SOCKET_TIMEOUT = 100;
const retryAfterOn413 = 2;
const connectTimeout = 500;
const socketTimeout = 100;

test.before('setup', async () => {
s = await createServer();
Expand Down Expand Up @@ -41,7 +41,7 @@ test.before('setup', async () => {

s.on('/measure413', (req, res) => {
res.writeHead(413, {
'Retry-After': RETRY_AFTER_ON_413
'Retry-After': retryAfterOn413
});
res.end((Date.now() - lastTried413access).toString());

Expand All @@ -50,7 +50,7 @@ test.before('setup', async () => {

s.on('/413', (req, res) => {
res.writeHead(413, {
'Retry-After': RETRY_AFTER_ON_413
'Retry-After': retryAfterOn413
});
res.end();
});
Expand All @@ -69,12 +69,12 @@ test.before('setup', async () => {
});

test('works on timeout error', async t => {
t.is((await got(`${s.url}/knock-twice`, {timeout: {connect: CONNECT_TIMEOUT, socket: SOCKET_TIMEOUT}})).body, 'who`s there?');
t.is((await got(`${s.url}/knock-twice`, {timeout: {connect: connectTimeout, socket: socketTimeout}})).body, 'who`s there?');
});

test('can be disabled with option', async t => {
const err = await t.throws(got(`${s.url}/try-me`, {
timeout: {connect: CONNECT_TIMEOUT, socket: SOCKET_TIMEOUT},
timeout: {connect: connectTimeout, socket: socketTimeout},
retry: 0
}));
t.truthy(err);
Expand All @@ -83,7 +83,7 @@ test('can be disabled with option', async t => {

test('function gets iter count', async t => {
await got(`${s.url}/fifth`, {
timeout: {connect: CONNECT_TIMEOUT, socket: SOCKET_TIMEOUT},
timeout: {connect: connectTimeout, socket: socketTimeout},
retry: {
retries: iteration => iteration < 10
}
Expand All @@ -93,7 +93,7 @@ test('function gets iter count', async t => {

test('falsy value prevents retries', async t => {
const err = await t.throws(got(`${s.url}/long`, {
timeout: {connect: CONNECT_TIMEOUT, socket: SOCKET_TIMEOUT},
timeout: {connect: connectTimeout, socket: socketTimeout},
retry: {
retries: () => 0
}
Expand All @@ -103,7 +103,7 @@ test('falsy value prevents retries', async t => {

test('falsy value prevents retries #2', async t => {
const err = await t.throws(got(`${s.url}/long`, {
timeout: {connect: CONNECT_TIMEOUT, socket: SOCKET_TIMEOUT},
timeout: {connect: connectTimeout, socket: socketTimeout},
retry: {
retries: (iter, err) => {
t.truthy(err);
Expand Down Expand Up @@ -143,7 +143,7 @@ test('respect 413 Retry-After', async t => {
retry: 1
});
t.is(statusCode, 413);
t.true(Number(body) >= RETRY_AFTER_ON_413 * 1000);
t.true(Number(body) >= retryAfterOn413 * 1000);
});

test('doesn\'t retry on 413 with empty statusCodes and methods', async t => {
Expand Down

0 comments on commit 918799f

Please sign in to comment.