@@ -39,23 +39,32 @@ describe('retry', () => {
39
39
[
40
40
{ options : { times : 5 , interval : 10 } , msg : 'times and interval' } ,
41
41
{ options : { times : 5 } , msg : 'just times' } ,
42
- { options : { } , msg : 'neither times nor interval' }
42
+ { options : { times : 5.4 } , msg : 'just times' } ,
43
+ { options : { times : Infinity } , msg : 'times = Infinity' } ,
44
+ { options : { } , msg : 'neither times nor interval' } ,
45
+ { options : { interval : Infinity } , msg : 'Should accept Infinity interval' }
43
46
] . forEach ( ( args ) => {
44
47
it ( `should accept first argument as an options hash with ${ args . msg } ` , ( ) => {
45
48
let retry = promiseTools . retry ( args . options , getTest ( 5 ) ) ;
46
49
return expect ( retry ) . to . eventually . equal ( 5 ) ;
47
50
} ) ;
48
51
} ) ;
49
52
53
+ it ( 'should call the default 5 times with no options provided' , ( ) => {
54
+ let retry = promiseTools . retry ( getTest ( 5 ) ) ;
55
+ return expect ( retry ) . to . eventually . equal ( 5 ) ;
56
+ } )
57
+
58
+ it ( 'should throw when given a bogus `times` option' , ( ) => {
59
+ let retry = promiseTools . retry ( '5' , getTest ( 5 ) ) ;
60
+ return expect ( retry ) . to . be . eventually . rejected ;
61
+ } )
62
+
50
63
it ( 'should return an error with invalid options argument' , ( ) => {
51
- let p = Promise . resolve ( ) . then ( ( ) => {
52
- // had to do this for some reason. Otherwise `chai-as-promised` always passed erroneously.
53
- try {
54
- return promiseTools . retry ( undefined , getTest ( 1 ) ) ;
55
- } catch ( err ) {
56
- throw err ;
57
- }
58
- } ) ;
59
- expect ( p ) . to . eventually . be . rejectedWith ( 'Unsupported argument type for \'times\': undefined' ) ;
64
+ expect ( promiseTools . retry ( undefined , getTest ( 1 ) ) ) . to . eventually . be . rejectedWith ( 'Unsupported argument type for \'times\': undefined' ) ;
60
65
} ) ;
66
+
67
+ it ( 'should reject when called with nothing' , ( ) => {
68
+ expect ( promiseTools . retry ( ) ) . to . eventually . be . rejectedWith ( 'No parameters given' ) ;
69
+ } )
61
70
} ) ;
0 commit comments