33 resolvePageArguments ,
44 resolveUserArguments ,
55 resolveAliasArguments ,
6- } from '../'
6+ } from '../index '
77import { Callback } from '../../events'
88import { User } from '../../user'
99
@@ -195,7 +195,7 @@ describe(resolveArguments, () => {
195195} )
196196
197197describe ( resolvePageArguments , ( ) => {
198- test ( 'empty strings ("", "", null , { integrations })' , ( ) => {
198+ test ( 'empty strings ("", "", {} , { integrations })' , ( ) => {
199199 const [ category , name , properties , options ] = resolvePageArguments (
200200 '' ,
201201 '' ,
@@ -211,14 +211,44 @@ describe(resolvePageArguments, () => {
211211
212212 expect ( category ) . toEqual ( '' )
213213 expect ( name ) . toEqual ( '' )
214- expect ( properties ) . toEqual ( { } )
215214 expect ( options ) . toEqual ( {
216215 integrations : {
217216 Amplitude : {
218217 sessionId : '123' ,
219218 } ,
220219 } ,
221220 } )
221+ expect ( properties ) . toEqual ( { } )
222+ } )
223+
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 )
222252 } )
223253
224254 test ( 'should accept (category, name, properties, callback)' , ( ) => {
@@ -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,6 +391,64 @@ describe(resolvePageArguments, () => {
365391 expect ( cb ) . toEqual ( fn )
366392 } )
367393
394+ test ( 'should accept (name, null, properties, options, callback)' , ( ) => {
395+ const fn = jest . fn ( )
396+ const [ category , name , properties , options , cb ] = resolvePageArguments (
397+ 'name' ,
398+ null ,
399+ bananaPhone ,
400+ baseOptions ,
401+ fn
402+ )
403+
404+ expect ( category ) . toEqual ( null )
405+ expect ( name ) . toEqual ( 'name' )
406+ expect ( properties ) . toEqual ( bananaPhone )
407+ expect ( options ) . toEqual ( baseOptions )
408+ expect ( cb ) . toEqual ( fn )
409+ } )
410+
411+ test ( 'should accept (name, null, properties)' , ( ) => {
412+ const [ category , name , properties , options ] = resolvePageArguments (
413+ 'name' ,
414+ null ,
415+ bananaPhone
416+ )
417+
418+ expect ( name ) . toEqual ( 'name' )
419+ expect ( category ) . toEqual ( null )
420+ expect ( properties ) . toEqual ( bananaPhone )
421+ expect ( options ) . toEqual ( { } )
422+ } )
423+
424+ test ( 'should accept (name, null, null, options)' , ( ) => {
425+ const [ category , name , properties , options ] = resolvePageArguments (
426+ 'name' ,
427+ null ,
428+ null ,
429+ baseOptions
430+ )
431+
432+ expect ( name ) . toEqual ( 'name' )
433+ expect ( category ) . toEqual ( null )
434+ expect ( properties ) . toEqual ( { } )
435+ expect ( options ) . toEqual ( baseOptions )
436+ } )
437+
438+ test ( 'should accept (null, null, properties)' , ( ) => {
439+ const [ category , name , properties , options , cb ] = resolvePageArguments (
440+ null ,
441+ null ,
442+ bananaPhone
443+ )
444+
445+ expect ( category ) . toEqual ( null )
446+ expect ( name ) . toEqual ( null )
447+ expect ( properties ) . toEqual ( bananaPhone )
448+ expect ( options ) . toEqual ( { } )
449+ expect ( cb ) . toEqual ( undefined )
450+ } )
451+
368452 test ( 'should accept (null, null, properties, options, callback)' , ( ) => {
369453 const fn = jest . fn ( )
370454 const [ category , name , properties , options , cb ] = resolvePageArguments (
@@ -425,6 +509,16 @@ describe(resolvePageArguments, () => {
425509 expect ( options ) . toEqual ( { } )
426510 expect ( cb ) . toEqual ( fn )
427511 } )
512+
513+ test ( 'should accept (null, null, null, null, callback)' , ( ) => {
514+ const fn = jest . fn ( )
515+ const [ category , name , properties , options , cb ] = resolvePageArguments ( fn )
516+ expect ( category ) . toEqual ( null )
517+ expect ( name ) . toEqual ( null )
518+ expect ( properties ) . toEqual ( { } )
519+ expect ( options ) . toEqual ( { } )
520+ expect ( cb ) . toEqual ( fn )
521+ } )
428522} )
429523
430524describe ( resolveUserArguments , ( ) => {
0 commit comments