@@ -110,48 +110,3 @@ describe('Core', () => {
110110 } ) . then ( done ) ;
111111 } ) ;
112112} ) ;
113-
114- describe ( 'retry' , ( ) => {
115- var MAX_ATTEMPTS = 5 ;
116- var RETURN_VALUE = 'hello' ;
117-
118- it ( 'only calls successful func once' , ( done ) => {
119- var spyFunc = jasmine . createSpy ( 'spyFunc' ) ;
120- spyFunc . and . returnValue ( Promise . resolve ( RETURN_VALUE ) ) ;
121- uproxy_core . retry ( spyFunc , MAX_ATTEMPTS ) . then ( ( x :any ) => {
122- expect ( spyFunc . calls . count ( ) ) . toEqual ( 1 ) ;
123- expect ( x ) . toEqual ( RETURN_VALUE ) ;
124- done ( ) ;
125- } ) ;
126- } ) ;
127-
128- it ( 'calls func multiple times until success' , ( done ) => {
129- var spyFunc = jasmine . createSpy ( 'spyFunc' ) ;
130- var callCount = 0 ;
131- var NUM_CALLS_BEFORE_SUCCESS = 3 ;
132- expect ( NUM_CALLS_BEFORE_SUCCESS ) . toBeLessThan ( MAX_ATTEMPTS ) ;
133- spyFunc . and . callFake ( ( ) => {
134- if ( ++ callCount === NUM_CALLS_BEFORE_SUCCESS ) {
135- return Promise . resolve ( RETURN_VALUE ) ;
136- } else {
137- return Promise . reject ( 'error' ) ;
138- }
139- } ) ;
140- uproxy_core . retry ( spyFunc , MAX_ATTEMPTS ) . then ( ( x :any ) => {
141- expect ( spyFunc . calls . count ( ) ) . toEqual ( NUM_CALLS_BEFORE_SUCCESS ) ;
142- expect ( x ) . toEqual ( RETURN_VALUE ) ;
143- done ( ) ;
144- } ) ;
145- } ) ;
146-
147- it ( 'stops calling failing func after the max number of tries' , ( done ) => {
148- var RETURN_VALUE = 'hello' ;
149- var spyFunc = jasmine . createSpy ( 'spyFunc' ) ;
150- spyFunc . and . returnValue ( Promise . reject ( RETURN_VALUE ) ) ;
151- uproxy_core . retry ( spyFunc , MAX_ATTEMPTS ) . catch ( ( x :any ) => {
152- expect ( spyFunc . calls . count ( ) ) . toEqual ( MAX_ATTEMPTS ) ;
153- expect ( x ) . toEqual ( RETURN_VALUE ) ;
154- done ( ) ;
155- } ) ;
156- } ) ;
157- } ) ;
0 commit comments