1+ const { buildParams } = require ( './helpers' )
12const SubCalendar = require ( '../lib/SubCalendar' )
23const Logger = require ( '../lib/Logger' )
34
@@ -19,63 +20,77 @@ describe('SubCalendar class', function () {
1920 test . each ( [ [ { includeInactive : true } ] , [ { includeInactive : false } ] ] ) (
2021 'valid options value' ,
2122 function ( options ) {
23+ const urlParams = buildParams ( options )
2224 API . listSubCalendars ( options )
2325
2426 expect ( Request . get ) . toHaveBeenCalledTimes ( 1 )
27+ expect ( Request . get ) . toHaveBeenCalledWith ( `/subcalendars?${ urlParams } ` )
2528 }
2629 )
2730
2831 test . each ( [
2932 [ { includeInactive : 'text' } ] ,
3033 [ { includeInactive : [ ] } ] ,
3134 [ { includeInactive : { } } ] ,
35+ [ { includeInactive : undefined } ] ,
36+ [ { includeInactive : 1234 } ] ,
3237 ] ) ( 'invalid options value' , function ( options ) {
3338 expect ( ( ) => API . listSubCalendars ( options ) ) . toThrow ( )
3439 } )
3540
36- test . each ( [
37- [ { } ] ,
38- [ { includeInactive : '' } ] ,
39- [ { includeInactive : null } ] ,
40- [ { includeInactive : undefined } ] ,
41- [ { includeInactive : 0 } ] ,
42- ] ) ( 'ignored options value' , function ( options ) {
43- API . listSubCalendars ( options )
41+ test . each ( [ [ { } ] , [ { includeInactive : null } ] ] ) (
42+ 'ignored options value' ,
43+ function ( options ) {
44+ API . listSubCalendars ( options )
4445
45- expect ( Request . get ) . toHaveBeenCalledTimes ( 1 )
46- } )
46+ expect ( Request . get ) . toHaveBeenCalledTimes ( 1 )
47+ expect ( Request . get ) . toHaveBeenCalledWith ( '/subcalendars' )
48+ }
49+ )
4750
4851 test ( 'invalid option parameter' , function ( ) {
4952 expect ( ( ) => API . listSubCalendars ( { someKey : true } ) ) . toThrow ( )
5053 } )
5154
52- test . each ( [ ( [ ] , 'string' , true , false , 123 ) ] ) (
55+ test . each ( [ ( [ ] , 'string' , true , false , 123 , null ) ] ) (
5356 'invalid options' ,
5457 function ( option ) {
5558 expect ( ( ) => API . listSubCalendars ( option ) ) . toThrow ( )
5659 }
5760 )
61+
62+ test ( 'ignored option: undefined' , function ( ) {
63+ API . listSubCalendars ( undefined )
64+
65+ expect ( Request . get ) . toHaveBeenCalledTimes ( 1 )
66+ expect ( Request . get ) . toHaveBeenCalledWith ( '/subcalendars' )
67+ } )
5868 } )
5969
6070 describe ( 'method: listSubCalendar' , function ( ) {
6171 test ( 'with id (number)' , function ( ) {
6272 API . listSubCalendar ( 1234 )
6373
6474 expect ( Request . get ) . toHaveBeenCalledTimes ( 1 )
75+ expect ( Request . get ) . toHaveBeenCalledWith ( '/subcalendars/1234' )
6576 } )
6677
6778 test ( 'with id (string)' , function ( ) {
6879 API . listSubCalendar ( '1234' )
6980
7081 expect ( Request . get ) . toHaveBeenCalledTimes ( 1 )
82+ expect ( Request . get ) . toHaveBeenCalledWith ( '/subcalendars/1234' )
7183 } )
7284
7385 test ( 'without id' , function ( ) {
7486 expect ( ( ) => API . listSubCalendar ( ) ) . toThrow ( )
7587 } )
7688
77- test . each ( [ [ ] , { } , true , false , 'text' ] ) ( 'invalid id' , function ( id ) {
78- expect ( ( ) => API . listSubCalendar ( id ) ) . toThrow ( )
79- } )
89+ test . each ( [ [ ] , { } , true , false , 'text' , null , undefined ] ) (
90+ 'invalid id' ,
91+ function ( id ) {
92+ expect ( ( ) => API . listSubCalendar ( id ) ) . toThrow ( )
93+ }
94+ )
8095 } )
8196} )
0 commit comments