import { MAX_ATTEMPTS, RETRY_DELAYS_MS, retryDelayMs, STALE_CLAIM_MS, } from './retry-policy'; describe('retry policy', () => { it('waits 30 s, 2 min, 10 min, 1 h and from the 5th failure on 6 h', () => { expect([1, 2, 3, 4, 5, 6, 7].map(retryDelayMs)).toEqual([ 30_000, 120_000, 600_000, 3_600_000, 21_600_000, 21_600_000, 21_600_000, ]); }); it('gives up after 8 attempts and treats a claim older than 5 min as stale', () => { expect(MAX_ATTEMPTS).toBe(8); expect(STALE_CLAIM_MS).toBe(300_000); expect(RETRY_DELAYS_MS).toEqual([ 30_000, 120_000, 600_000, 3_600_000, 21_600_000, ]); }); it.each([0, -1, 1.5, Number.NaN])( 'refuses %p failed attempts - a delay exists only after a failure', (attempts) => { expect(() => retryDelayMs(attempts)).toThrow(RangeError); }, ); });