1
1
import { Navigation } from 'react-native-navigation'
2
- import createNavigationHelpers from './createNavigationHelpers '
2
+ import createNavigationCommands from './createNavigationCommands '
3
3
4
4
jest . mock ( 'react-native-navigation' , ( ) => ( {
5
5
Navigation : {
@@ -16,14 +16,14 @@ jest.mock('react-native-navigation', () => ({
16
16
popToRoot : jest . fn ( ) ,
17
17
dismissOverlay : jest . fn ( ) ,
18
18
getLaunchArgs : jest . fn ( ) ,
19
- events : jest . fn ( ) ,
19
+ setDefaultOptions : jest . fn ( ) ,
20
20
dismissAllModals : jest . fn ( ) ,
21
21
} ,
22
22
} ) )
23
23
24
- describe ( 'createNavigationHelpers ' , ( ) => {
24
+ describe ( 'createNavigationCommands ' , ( ) => {
25
25
describe ( 'setRoot' , ( ) => {
26
- const { setRoot } = createNavigationHelpers ( 'componentId' )
26
+ const { setRoot } = createNavigationCommands ( 'componentId' )
27
27
28
28
it ( 'should call Navigation.setRoot using name' , async ( ) => {
29
29
await setRoot ( 'componentName' )
@@ -113,7 +113,7 @@ describe('createNavigationHelpers', () => {
113
113
} )
114
114
115
115
describe ( 'setStackRoot' , ( ) => {
116
- const { setStackRoot } = createNavigationHelpers ( 'componentId' )
116
+ const { setStackRoot } = createNavigationCommands ( 'componentId' )
117
117
118
118
it ( 'should call Navigation.setStackRoot using name' , async ( ) => {
119
119
await setStackRoot ( 'componentName' )
@@ -175,7 +175,7 @@ describe('createNavigationHelpers', () => {
175
175
} )
176
176
177
177
describe ( 'push' , ( ) => {
178
- const { push } = createNavigationHelpers ( 'componentId' )
178
+ const { push } = createNavigationCommands ( 'componentId' )
179
179
180
180
it ( 'should call Navigation.push using name' , async ( ) => {
181
181
await push ( 'componentName' )
@@ -237,7 +237,7 @@ describe('createNavigationHelpers', () => {
237
237
} )
238
238
239
239
describe ( 'showModal' , ( ) => {
240
- const { showModal } = createNavigationHelpers ( 'componentId' )
240
+ const { showModal } = createNavigationCommands ( 'componentId' )
241
241
242
242
it ( 'should call Navigation.showModal using name' , async ( ) => {
243
243
await showModal ( 'componentName' )
@@ -298,126 +298,8 @@ describe('createNavigationHelpers', () => {
298
298
} )
299
299
} )
300
300
301
- describe ( 'showModalStack' , ( ) => {
302
- const { showModalStack } = createNavigationHelpers ( 'componentId' )
303
-
304
- it ( 'should call Navigation.showModal using name' , async ( ) => {
305
- await showModalStack ( 'componentName' )
306
-
307
- expect ( Navigation . showModal ) . toHaveBeenCalledWith ( {
308
- stack : {
309
- children : [
310
- {
311
- component : {
312
- name : 'componentName' ,
313
- } ,
314
- } ,
315
- ] ,
316
- } ,
317
- } )
318
- } )
319
-
320
- it ( 'should call Navigation.showModal using name and passProps' , async ( ) => {
321
- await showModalStack ( 'componentName' , { prop1 : 'value1' } )
322
-
323
- expect ( Navigation . showModal ) . toHaveBeenCalledWith ( {
324
- stack : {
325
- children : [
326
- {
327
- component : {
328
- name : 'componentName' ,
329
- passProps : { prop1 : 'value1' } ,
330
- } ,
331
- } ,
332
- ] ,
333
- } ,
334
- } )
335
- } )
336
-
337
- it ( 'should call Navigation.showModal using name, passProps and options' , async ( ) => {
338
- await showModalStack ( 'componentName' , { prop1 : 'value1' } , { popGesture : true } )
339
-
340
- expect ( Navigation . showModal ) . toHaveBeenCalledWith ( {
341
- stack : {
342
- children : [
343
- {
344
- component : {
345
- name : 'componentName' ,
346
- passProps : { prop1 : 'value1' } ,
347
- options : { popGesture : true } ,
348
- } ,
349
- } ,
350
- ] ,
351
- } ,
352
- } )
353
- } )
354
-
355
- it ( 'should call Navigation.showModal using name and options' , async ( ) => {
356
- await showModalStack ( 'componentName' , undefined , { popGesture : true } )
357
-
358
- expect ( Navigation . showModal ) . toHaveBeenCalledWith ( {
359
- stack : {
360
- children : [
361
- {
362
- component : {
363
- name : 'componentName' ,
364
- options : { popGesture : true } ,
365
- } ,
366
- } ,
367
- ] ,
368
- } ,
369
- } )
370
- } )
371
-
372
- it ( 'should call Navigation.showModal using a LayoutStackChildren' , async ( ) => {
373
- await showModalStack ( {
374
- component : { name : 'componentName' } ,
375
- externalComponent : { name : 'externalComponentName' } ,
376
- } )
377
-
378
- expect ( Navigation . showModal ) . toHaveBeenCalledWith ( {
379
- stack : {
380
- children : [
381
- {
382
- component : { name : 'componentName' } ,
383
- externalComponent : { name : 'externalComponentName' } ,
384
- } ,
385
- ] ,
386
- } ,
387
- } )
388
- } )
389
-
390
- it ( 'should call Navigation.showModal when LayoutStackChildren[] provided' , async ( ) => {
391
- await showModalStack ( [
392
- {
393
- component : { name : 'component1' } ,
394
- externalComponent : { name : 'externalComponentName1' } ,
395
- } ,
396
- {
397
- component : { name : 'component2' } ,
398
- externalComponent : { name : 'externalComponentName2' } ,
399
- } ,
400
- ] )
401
-
402
- expect ( Navigation . showModal ) . toHaveBeenCalledWith ( {
403
- stack : {
404
- children : [
405
- {
406
- component : { name : 'component1' } ,
407
- externalComponent : { name : 'externalComponentName1' } ,
408
- } ,
409
- {
410
- component : { name : 'component2' } ,
411
- externalComponent : { name : 'externalComponentName2' } ,
412
- } ,
413
- ] ,
414
- } ,
415
- } )
416
- } )
417
- } )
418
-
419
301
describe ( 'showOverlay' , ( ) => {
420
- const { showOverlay } = createNavigationHelpers ( 'componentId' )
302
+ const { showOverlay } = createNavigationCommands ( 'componentId' )
421
303
422
304
it ( 'should call Navigation.showOverlay using name' , async ( ) => {
423
305
await showOverlay ( 'componentName' )
@@ -479,7 +361,7 @@ describe('createNavigationHelpers', () => {
479
361
} )
480
362
481
363
describe ( 'mergeOptions' , ( ) => {
482
- const { mergeOptions } = createNavigationHelpers ( 'componentId' )
364
+ const { mergeOptions } = createNavigationCommands ( 'componentId' )
483
365
484
366
it ( 'should call Navigation.mergeOptions with componentId' , ( ) => {
485
367
mergeOptions ( { popGesture : true } )
@@ -489,7 +371,7 @@ describe('createNavigationHelpers', () => {
489
371
} )
490
372
491
373
describe ( 'updateProps' , ( ) => {
492
- const { updateProps } = createNavigationHelpers ( 'componentId' )
374
+ const { updateProps } = createNavigationCommands ( 'componentId' )
493
375
494
376
it ( 'should call Navigation.updateProps with componentId' , ( ) => {
495
377
updateProps ( { prop1 : 'value1' } )
@@ -499,7 +381,7 @@ describe('createNavigationHelpers', () => {
499
381
} )
500
382
501
383
describe ( 'dismissModal' , ( ) => {
502
- const { dismissModal } = createNavigationHelpers ( 'componentId' )
384
+ const { dismissModal } = createNavigationCommands ( 'componentId' )
503
385
504
386
it ( 'should call Navigation.dismissModal with componentId' , async ( ) => {
505
387
await dismissModal ( )
@@ -521,7 +403,7 @@ describe('createNavigationHelpers', () => {
521
403
} )
522
404
523
405
describe ( 'pop' , ( ) => {
524
- const { pop } = createNavigationHelpers ( 'componentId' )
406
+ const { pop } = createNavigationCommands ( 'componentId' )
525
407
526
408
it ( 'should call Navigation.pop with componentId' , async ( ) => {
527
409
await pop ( )
@@ -537,7 +419,7 @@ describe('createNavigationHelpers', () => {
537
419
} )
538
420
539
421
describe ( 'popTo' , ( ) => {
540
- const { popTo } = createNavigationHelpers ( 'componentId' )
422
+ const { popTo } = createNavigationCommands ( 'componentId' )
541
423
542
424
it ( 'should call Navigation.popTo with componentId' , async ( ) => {
543
425
await popTo ( )
@@ -553,7 +435,7 @@ describe('createNavigationHelpers', () => {
553
435
} )
554
436
555
437
describe ( 'popToRoot' , ( ) => {
556
- const { popToRoot } = createNavigationHelpers ( 'componentId' )
438
+ const { popToRoot } = createNavigationCommands ( 'componentId' )
557
439
558
440
it ( 'should call Navigation.popToRoot with componentId' , async ( ) => {
559
441
await popToRoot ( )
@@ -569,7 +451,7 @@ describe('createNavigationHelpers', () => {
569
451
} )
570
452
571
453
describe ( 'dismissOverlay' , ( ) => {
572
- const { dismissOverlay } = createNavigationHelpers ( 'componentId' )
454
+ const { dismissOverlay } = createNavigationCommands ( 'componentId' )
573
455
574
456
it ( 'should call Navigation.dismissOverlay with componentId' , async ( ) => {
575
457
await dismissOverlay ( )
@@ -579,17 +461,17 @@ describe('createNavigationHelpers', () => {
579
461
} )
580
462
581
463
describe ( 'events' , ( ) => {
582
- const { events } = createNavigationHelpers ( 'componentId' )
464
+ const { setDefaultOptions } = createNavigationCommands ( 'componentId' )
583
465
584
- it ( 'should return Navigation.events function as is' , ( ) => {
585
- events ( )
466
+ it ( 'should return Navigation.setDefaultOptions function as is' , ( ) => {
467
+ setDefaultOptions ( { } )
586
468
587
- expect ( Navigation . events ) . toHaveBeenCalled ( )
469
+ expect ( Navigation . setDefaultOptions ) . toHaveBeenCalledWith ( { } )
588
470
} )
589
471
} )
590
472
591
473
describe ( 'getLaunchArgs' , ( ) => {
592
- const { getLaunchArgs } = createNavigationHelpers ( 'componentId' )
474
+ const { getLaunchArgs } = createNavigationCommands ( 'componentId' )
593
475
594
476
it ( 'should return Navigation.getLaunchArgs function as is' , async ( ) => {
595
477
await getLaunchArgs ( )
@@ -599,7 +481,7 @@ describe('createNavigationHelpers', () => {
599
481
} )
600
482
601
483
describe ( 'dismissAllModals' , ( ) => {
602
- const { dismissAllModals } = createNavigationHelpers ( 'componentId' )
484
+ const { dismissAllModals } = createNavigationCommands ( 'componentId' )
603
485
604
486
it ( 'should return Navigation.dismissAllModals function as is' , async ( ) => {
605
487
await dismissAllModals ( )
0 commit comments