@@ -194,7 +194,7 @@ describe(resolveArguments, () => {
194194 } )
195195} )
196196
197- describe ( resolvePageArguments , ( ) => {
197+ describe ( ' resolvePageArguments - analytics.page([category], [name], [properties], [options], [callback])' , ( ) => {
198198 test ( 'empty strings ("", "", null, { integrations })' , ( ) => {
199199 const [ category , name , properties , options ] = resolvePageArguments (
200200 '' ,
@@ -221,6 +221,36 @@ describe(resolvePageArguments, () => {
221221 } )
222222 } )
223223
224+ it ( 'should accept (category, name)' , ( ) => {
225+ const [ category , name , properties , options , cb ] = resolvePageArguments (
226+ 'category' ,
227+ 'name'
228+ )
229+
230+ expect ( name ) . toEqual ( 'name' )
231+ expect ( category ) . toEqual ( 'category' )
232+ expect ( properties ) . toEqual ( { } )
233+ expect ( options ) . toEqual ( { } )
234+ expect ( cb ) . toEqual ( undefined )
235+ } )
236+
237+ it ( 'should accept (category, name, properties, options, cb)' , ( ) => {
238+ const fn = jest . fn ( )
239+ const [ category , name , properties , options , cb ] = resolvePageArguments (
240+ 'foo' ,
241+ 'name' ,
242+ bananaPhone ,
243+ baseOptions ,
244+ fn
245+ )
246+
247+ expect ( category ) . toEqual ( 'foo' )
248+ expect ( name ) . toEqual ( 'name' )
249+ expect ( properties ) . toEqual ( bananaPhone )
250+ expect ( options ) . toEqual ( baseOptions )
251+ expect ( cb ) . toEqual ( fn )
252+ } )
253+
224254 test ( 'should accept (category, name, properties, callback)' , ( ) => {
225255 const fn = jest . fn ( )
226256 const [ category , name , properties , options , cb ] = resolvePageArguments (
@@ -254,52 +284,48 @@ describe(resolvePageArguments, () => {
254284 expect ( options ) . toEqual ( { } )
255285 } )
256286
257- it ( 'should accept (name, properties, options, callback)' , ( ) => {
258- const fn = jest . fn ( )
287+ it ( 'should accept (name, properties)' , ( ) => {
259288 const [ category , name , properties , options , cb ] = resolvePageArguments (
260289 'name' ,
261- bananaPhone ,
262- baseOptions ,
263- fn
290+ bananaPhone
264291 )
265292
266- expect ( category ) . toEqual ( null )
267293 expect ( name ) . toEqual ( 'name' )
294+ expect ( category ) . toEqual ( null )
268295 expect ( properties ) . toEqual ( bananaPhone )
269- expect ( options ) . toEqual ( baseOptions )
270- expect ( cb ) . toEqual ( fn )
296+ expect ( options ) . toEqual ( { } )
297+ expect ( cb ) . toEqual ( undefined )
271298 } )
272299
273- it ( 'should accept (name, properties, callback)' , ( ) => {
300+ it ( 'should accept (name, properties, options, callback)' , ( ) => {
274301 const fn = jest . fn ( )
275302 const [ category , name , properties , options , cb ] = resolvePageArguments (
276303 'name' ,
277304 bananaPhone ,
305+ baseOptions ,
278306 fn
279307 )
280308
281309 expect ( category ) . toEqual ( null )
282310 expect ( name ) . toEqual ( 'name' )
283311 expect ( properties ) . toEqual ( bananaPhone )
312+ expect ( options ) . toEqual ( baseOptions )
284313 expect ( cb ) . toEqual ( fn )
285- expect ( options ) . toEqual ( { } )
286314 } )
287315
288- it ( 'should accept (category, name, properties, options, cb )' , ( ) => {
316+ it ( 'should accept (name, properties, callback )' , ( ) => {
289317 const fn = jest . fn ( )
290318 const [ category , name , properties , options , cb ] = resolvePageArguments (
291- 'foo' ,
292319 'name' ,
293320 bananaPhone ,
294- baseOptions ,
295321 fn
296322 )
297323
298- expect ( category ) . toEqual ( 'foo' )
324+ expect ( category ) . toEqual ( null )
299325 expect ( name ) . toEqual ( 'name' )
300326 expect ( properties ) . toEqual ( bananaPhone )
301- expect ( options ) . toEqual ( baseOptions )
302327 expect ( cb ) . toEqual ( fn )
328+ expect ( options ) . toEqual ( { } )
303329 } )
304330
305331 it ( 'should accept (name, callback)' , ( ) => {
@@ -348,7 +374,7 @@ describe(resolvePageArguments, () => {
348374 expect ( category ) . toEqual ( null )
349375 } )
350376
351- test ( 'should accept (category = null, name, properties, options, callback)' , ( ) => {
377+ test ( 'should accept (null, name, properties, options, callback)' , ( ) => {
352378 const fn = jest . fn ( )
353379 const [ category , name , properties , options , cb ] = resolvePageArguments (
354380 null ,
@@ -365,7 +391,7 @@ describe(resolvePageArguments, () => {
365391 expect ( cb ) . toEqual ( fn )
366392 } )
367393
368- test ( 'should accept (category, name = null, properties, options, callback)' , ( ) => {
394+ test ( 'should accept (category, null, properties, options, callback)' , ( ) => {
369395 const fn = jest . fn ( )
370396 const [ category , name , properties , options , cb ] = resolvePageArguments (
371397 'category' ,
@@ -376,12 +402,43 @@ describe(resolvePageArguments, () => {
376402 )
377403
378404 expect ( category ) . toEqual ( 'category' )
379- expect ( name ) . toEqual ( 'name' )
405+ expect ( name ) . toEqual ( null )
380406 expect ( properties ) . toEqual ( bananaPhone )
381407 expect ( options ) . toEqual ( baseOptions )
382408 expect ( cb ) . toEqual ( fn )
383409 } )
384410
411+ test ( 'should accept (category, undefined, properties, options, callback)' , ( ) => {
412+ const fn = jest . fn ( )
413+ const [ category , name , properties , options , cb ] = resolvePageArguments (
414+ 'category' ,
415+ undefined ,
416+ bananaPhone ,
417+ baseOptions ,
418+ fn
419+ )
420+
421+ expect ( category ) . toEqual ( 'category' )
422+ expect ( name ) . toEqual ( undefined )
423+ expect ( properties ) . toEqual ( bananaPhone )
424+ expect ( options ) . toEqual ( baseOptions )
425+ expect ( cb ) . toEqual ( fn )
426+ } )
427+
428+ test ( 'should accept (null, null, properties)' , ( ) => {
429+ const [ category , name , properties , options , cb ] = resolvePageArguments (
430+ null ,
431+ null ,
432+ bananaPhone
433+ )
434+
435+ expect ( category ) . toEqual ( null )
436+ expect ( name ) . toEqual ( null )
437+ expect ( properties ) . toEqual ( bananaPhone )
438+ expect ( options ) . toEqual ( { } )
439+ expect ( cb ) . toEqual ( undefined )
440+ } )
441+
385442 test ( 'should accept (null, null, properties, options, callback)' , ( ) => {
386443 const fn = jest . fn ( )
387444 const [ category , name , properties , options , cb ] = resolvePageArguments (
@@ -442,6 +499,16 @@ describe(resolvePageArguments, () => {
442499 expect ( options ) . toEqual ( { } )
443500 expect ( cb ) . toEqual ( fn )
444501 } )
502+
503+ test ( 'should accept (null, null, null, null, callback)' , ( ) => {
504+ const fn = jest . fn ( )
505+ const [ category , name , properties , options , cb ] = resolvePageArguments ( fn )
506+ expect ( category ) . toEqual ( null )
507+ expect ( name ) . toEqual ( null )
508+ expect ( properties ) . toEqual ( { } )
509+ expect ( options ) . toEqual ( { } )
510+ expect ( cb ) . toEqual ( fn )
511+ } )
445512} )
446513
447514describe ( resolveUserArguments , ( ) => {
0 commit comments