3
3
resolvePageArguments ,
4
4
resolveUserArguments ,
5
5
resolveAliasArguments ,
6
- } from '../'
6
+ } from '../index '
7
7
import { Callback } from '../../events'
8
8
import { User } from '../../user'
9
9
@@ -219,6 +219,37 @@ describe(resolvePageArguments, () => {
219
219
} ,
220
220
} ,
221
221
} )
222
+ expect ( properties ) . toEqual ( { } )
223
+ } )
224
+
225
+ it ( 'should accept (category, name)' , ( ) => {
226
+ const [ category , name , properties , options , cb ] = resolvePageArguments (
227
+ 'category' ,
228
+ 'name'
229
+ )
230
+
231
+ expect ( name ) . toEqual ( 'name' )
232
+ expect ( category ) . toEqual ( 'category' )
233
+ expect ( properties ) . toEqual ( { } )
234
+ expect ( options ) . toEqual ( { } )
235
+ expect ( cb ) . toEqual ( undefined )
236
+ } )
237
+
238
+ it ( 'should accept (category, name, properties, options, cb)' , ( ) => {
239
+ const fn = jest . fn ( )
240
+ const [ category , name , properties , options , cb ] = resolvePageArguments (
241
+ 'foo' ,
242
+ 'name' ,
243
+ bananaPhone ,
244
+ baseOptions ,
245
+ fn
246
+ )
247
+
248
+ expect ( category ) . toEqual ( 'foo' )
249
+ expect ( name ) . toEqual ( 'name' )
250
+ expect ( properties ) . toEqual ( bananaPhone )
251
+ expect ( options ) . toEqual ( baseOptions )
252
+ expect ( cb ) . toEqual ( fn )
222
253
} )
223
254
224
255
test ( 'should accept (category, name, properties, callback)' , ( ) => {
@@ -254,52 +285,48 @@ describe(resolvePageArguments, () => {
254
285
expect ( options ) . toEqual ( { } )
255
286
} )
256
287
257
- it ( 'should accept (name, properties, options, callback)' , ( ) => {
258
- const fn = jest . fn ( )
288
+ it ( 'should accept (name, properties)' , ( ) => {
259
289
const [ category , name , properties , options , cb ] = resolvePageArguments (
260
290
'name' ,
261
- bananaPhone ,
262
- baseOptions ,
263
- fn
291
+ bananaPhone
264
292
)
265
293
266
- expect ( category ) . toEqual ( null )
267
294
expect ( name ) . toEqual ( 'name' )
295
+ expect ( category ) . toEqual ( null )
268
296
expect ( properties ) . toEqual ( bananaPhone )
269
- expect ( options ) . toEqual ( baseOptions )
270
- expect ( cb ) . toEqual ( fn )
297
+ expect ( options ) . toEqual ( { } )
298
+ expect ( cb ) . toEqual ( undefined )
271
299
} )
272
300
273
- it ( 'should accept (name, properties, callback)' , ( ) => {
301
+ it ( 'should accept (name, properties, options, callback)' , ( ) => {
274
302
const fn = jest . fn ( )
275
303
const [ category , name , properties , options , cb ] = resolvePageArguments (
276
304
'name' ,
277
305
bananaPhone ,
306
+ baseOptions ,
278
307
fn
279
308
)
280
309
281
310
expect ( category ) . toEqual ( null )
282
311
expect ( name ) . toEqual ( 'name' )
283
312
expect ( properties ) . toEqual ( bananaPhone )
313
+ expect ( options ) . toEqual ( baseOptions )
284
314
expect ( cb ) . toEqual ( fn )
285
- expect ( options ) . toEqual ( { } )
286
315
} )
287
316
288
- it ( 'should accept (category, name, properties, options, cb )' , ( ) => {
317
+ it ( 'should accept (name, properties, callback )' , ( ) => {
289
318
const fn = jest . fn ( )
290
319
const [ category , name , properties , options , cb ] = resolvePageArguments (
291
- 'foo' ,
292
320
'name' ,
293
321
bananaPhone ,
294
- baseOptions ,
295
322
fn
296
323
)
297
324
298
- expect ( category ) . toEqual ( 'foo' )
325
+ expect ( category ) . toEqual ( null )
299
326
expect ( name ) . toEqual ( 'name' )
300
327
expect ( properties ) . toEqual ( bananaPhone )
301
- expect ( options ) . toEqual ( baseOptions )
302
328
expect ( cb ) . toEqual ( fn )
329
+ expect ( options ) . toEqual ( { } )
303
330
} )
304
331
305
332
it ( 'should accept (name, callback)' , ( ) => {
@@ -348,7 +375,7 @@ describe(resolvePageArguments, () => {
348
375
expect ( category ) . toEqual ( null )
349
376
} )
350
377
351
- test ( 'should accept (category = null, name, properties, options, callback)' , ( ) => {
378
+ test ( 'should accept (null, name, properties, options, callback)' , ( ) => {
352
379
const fn = jest . fn ( )
353
380
const [ category , name , properties , options , cb ] = resolvePageArguments (
354
381
null ,
@@ -365,6 +392,64 @@ describe(resolvePageArguments, () => {
365
392
expect ( cb ) . toEqual ( fn )
366
393
} )
367
394
395
+ test ( 'should accept (name, null, properties, options, callback)' , ( ) => {
396
+ const fn = jest . fn ( )
397
+ const [ category , name , properties , options , cb ] = resolvePageArguments (
398
+ 'name' ,
399
+ null ,
400
+ bananaPhone ,
401
+ baseOptions ,
402
+ fn
403
+ )
404
+
405
+ expect ( category ) . toEqual ( null )
406
+ expect ( name ) . toEqual ( 'name' )
407
+ expect ( properties ) . toEqual ( bananaPhone )
408
+ expect ( options ) . toEqual ( baseOptions )
409
+ expect ( cb ) . toEqual ( fn )
410
+ } )
411
+
412
+ test ( 'should accept (name, null, properties)' , ( ) => {
413
+ const [ category , name , properties , options ] = resolvePageArguments (
414
+ 'name' ,
415
+ null ,
416
+ bananaPhone
417
+ )
418
+
419
+ expect ( name ) . toEqual ( 'name' )
420
+ expect ( category ) . toEqual ( null )
421
+ expect ( properties ) . toEqual ( bananaPhone )
422
+ expect ( options ) . toEqual ( { } )
423
+ } )
424
+
425
+ test ( 'should accept (name, null, null, options)' , ( ) => {
426
+ const [ category , name , properties , options ] = resolvePageArguments (
427
+ 'name' ,
428
+ null ,
429
+ null ,
430
+ baseOptions
431
+ )
432
+
433
+ expect ( name ) . toEqual ( 'name' )
434
+ expect ( category ) . toEqual ( null )
435
+ expect ( properties ) . toEqual ( { } )
436
+ expect ( options ) . toEqual ( baseOptions )
437
+ } )
438
+
439
+ test ( 'should accept (null, null, properties)' , ( ) => {
440
+ const [ category , name , properties , options , cb ] = resolvePageArguments (
441
+ null ,
442
+ null ,
443
+ bananaPhone
444
+ )
445
+
446
+ expect ( category ) . toEqual ( null )
447
+ expect ( name ) . toEqual ( null )
448
+ expect ( properties ) . toEqual ( bananaPhone )
449
+ expect ( options ) . toEqual ( { } )
450
+ expect ( cb ) . toEqual ( undefined )
451
+ } )
452
+
368
453
test ( 'should accept (null, null, properties, options, callback)' , ( ) => {
369
454
const fn = jest . fn ( )
370
455
const [ category , name , properties , options , cb ] = resolvePageArguments (
@@ -425,6 +510,16 @@ describe(resolvePageArguments, () => {
425
510
expect ( options ) . toEqual ( { } )
426
511
expect ( cb ) . toEqual ( fn )
427
512
} )
513
+
514
+ test ( 'should accept (null, null, null, null, callback)' , ( ) => {
515
+ const fn = jest . fn ( )
516
+ const [ category , name , properties , options , cb ] = resolvePageArguments ( fn )
517
+ expect ( category ) . toEqual ( null )
518
+ expect ( name ) . toEqual ( null )
519
+ expect ( properties ) . toEqual ( { } )
520
+ expect ( options ) . toEqual ( { } )
521
+ expect ( cb ) . toEqual ( fn )
522
+ } )
428
523
} )
429
524
430
525
describe ( resolveUserArguments , ( ) => {
0 commit comments