backoff-rxjs
Advanced tools
Comparing version 6.1.0 to 6.1.1
{ | ||
"name": "backoff-rxjs", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"description": "A collection of helpful RxJS operators to deal with backoff strategies (like exponential backoff)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -300,2 +300,55 @@ import { expect } from 'chai'; | ||
}); | ||
it('should retry until shouldRetry is true', (done: MochaDone) => { | ||
let errors = 0; | ||
const retries = 2; | ||
const isNotSoBad = (error: any) => error === 'not so bad'; | ||
Observable.create((observer: Observer<number>) => { | ||
observer.next(42); | ||
observer.complete(); | ||
}) | ||
.pipe( | ||
map((x: any) => { | ||
errors += 1; | ||
throw errors < 2 ? 'not so bad' : 'really bad'; | ||
}), | ||
retryBackoff({ initialInterval: 1, shouldRetry: isNotSoBad }) | ||
) | ||
.subscribe( | ||
() => {}, | ||
(err: any) => { | ||
expect(errors).to.equal(2); | ||
expect(err).to.equal('really bad'); | ||
done(); | ||
} | ||
); | ||
}); | ||
it('should increase the intervals calculated by backoffDelay function', () => { | ||
testScheduler.run(({ expectObservable, cold, expectSubscriptions }) => { | ||
const constantDelay = (iteration: number, initialInterval: number) => | ||
initialInterval; | ||
const source = cold('-1-#'); | ||
const subs = [ | ||
' ^--!', | ||
' ----^--!', | ||
' --------^--!', | ||
' ------------^--!', | ||
' ----------------^--!' | ||
]; | ||
const unsub = ' -------------------!'; | ||
const expected = ' -1---1---1---1---1--'; | ||
expectObservable( | ||
source.pipe( | ||
retryBackoff({ | ||
initialInterval: 1, | ||
backoffDelay: constantDelay | ||
}) | ||
), | ||
unsub | ||
).toBe(expected); | ||
expectSubscriptions(source.subscriptions).toBe(subs); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57547
23
596