@@ -39,6 +39,8 @@ 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 : { times : 5.4 } , msg : 'just times' } ,
43
+ { options : { times : Infinity } , msg : 'times = Infinity' } ,
42
44
{ options : { } , msg : 'neither times nor interval' }
43
45
] . forEach ( ( args ) => {
44
46
it ( `should accept first argument as an options hash with ${ args . msg } ` , ( ) => {
@@ -47,15 +49,21 @@ describe('retry', () => {
47
49
} ) ;
48
50
} ) ;
49
51
52
+ it ( 'should call the default 5 times with no options provided' , ( ) => {
53
+ let retry = promiseTools . retry ( getTest ( 5 ) ) ;
54
+ return expect ( retry ) . to . eventually . equal ( 5 ) ;
55
+ } )
56
+
57
+ it ( 'should throw when given a bogus `times` option' , ( ) => {
58
+ let retry = promiseTools . retry ( '5' , getTest ( 5 ) ) ;
59
+ return expect ( retry ) . to . be . eventually . rejected ;
60
+ } )
61
+
50
62
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' ) ;
63
+ expect ( promiseTools . retry ( undefined , getTest ( 1 ) ) ) . to . eventually . be . rejectedWith ( 'Unsupported argument type for \'times\': undefined' ) ;
60
64
} ) ;
65
+
66
+ it ( 'should reject when called with nothing' , ( ) => {
67
+ expect ( promiseTools . retry ( ) ) . to . eventually . be . rejectedWith ( 'No parameters given' ) ;
68
+ } )
61
69
} ) ;
0 commit comments