Move calculateDelay back to private. Move abort signal check
This commit is contained in:
@@ -586,27 +586,6 @@ const testExponentialBackoffValidateOptionsRejectsNaN = (): void => {
|
||||
}
|
||||
};
|
||||
|
||||
/** Tests that calculateDelay will not result in NaN from extremely large growth rates and attempts */
|
||||
const testExponentialBackoffCalculateDelayDoesNotResultInNaN = (): void => {
|
||||
// Large number, 1 trillion.
|
||||
// Theory being that 1 trillion to the power of 1 trillion should be a very large number and cause either an unsafe value or a NaN.
|
||||
const largeNumber = 1_000_000_000_000;
|
||||
|
||||
// Test the calculateDelay function
|
||||
const result = ExponentialBackoff.calculateDelay(
|
||||
{
|
||||
baseDelay: 10000,
|
||||
growthRate: largeNumber,
|
||||
jitter: 0,
|
||||
maxDelay: 10_000,
|
||||
maxAttempts: largeNumber,
|
||||
},
|
||||
largeNumber,
|
||||
);
|
||||
|
||||
// Test to ensure it was bounded to the max delay
|
||||
expect(result).toBe(10_000);
|
||||
};
|
||||
|
||||
/** Tests that passing undefined into the constructor does not cause an error during spread */
|
||||
const testExponentialBackoffConstructorDoesNotCauseErrorDuringSpread = async (): Promise<void> => {
|
||||
@@ -649,10 +628,6 @@ const runTests = async (): Promise<void> => {
|
||||
test('ExponentialBackoff.validateOptions: rejects Infinity', testExponentialBackoffValidateOptionsRejectsNonFiniteValues);
|
||||
test('ExponentialBackoff.validateOptions: rejects non-integer values', testExponentialBackoffValidateOptionsRejectsNonIntegerValues);
|
||||
test('ExponentialBackoff.validateOptions: rejects NaN', testExponentialBackoffValidateOptionsRejectsNaN);
|
||||
test(
|
||||
'ExponentialBackoff: calculateDelay does not result in NaN from extremely large growth rates and attempts',
|
||||
testExponentialBackoffCalculateDelayDoesNotResultInNaN,
|
||||
);
|
||||
test('ExponentialBackoff: constructor does not cause an error during spread', testExponentialBackoffConstructorDoesNotCauseErrorDuringSpread);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user