@@ -459,14 +459,14 @@ describe('Picker component', () => {
459
459
} )
460
460
} )
461
461
462
- it ( 'should render helper Items is defined ' , async ( ) => {
463
- const helperItems = [ { Id : 1 , Name : 'Item1' , DisplayName : 'Display Item1' , Path : '/Root/Content/EN/Blog/Posts' } ]
462
+ it ( 'should render helper Current Conten based on SelectionRoot ' , async ( ) => {
463
+ let helperItems = { Id : 1 , Name : 'Item1' , DisplayName : 'Display Item1' , Path : '/Root/Content/EN/Blog/Posts' }
464
464
465
465
let wrapper : any
466
466
await act ( async ( ) => {
467
467
wrapper = mount (
468
468
< Picker
469
- selectionRoots = { [ '/Root/Content/EN/Blog/Posts' , '/Root/Content/img' ] }
469
+ selectionRoots = { [ '/Root/Content/EN/Blog/Posts' ] }
470
470
contextPath = "/Root/Content/EN/Blog/Posts"
471
471
repository = { repository ( genericContentItems , helperItems ) as any }
472
472
/> ,
@@ -477,11 +477,89 @@ describe('Picker component', () => {
477
477
478
478
//data-test current-content should be rendered
479
479
480
- expect ( wrapper . find ( "[data-test='current-content']" ) . exists ( ) ) . toBeTruthy ( )
480
+ expect (
481
+ wrapper
482
+ . find ( Link )
483
+ . filterWhere ( ( n ) => n . prop ( 'data-test' ) === 'current-content' )
484
+ . exists ( ) ,
485
+ ) . toBeTruthy ( )
486
+
487
+ helperItems = { Id : 1 , Name : 'Item1' , DisplayName : 'Display Item1' , Path : '/Root/Content/HU/Blog/Posts' }
488
+
489
+ await act ( async ( ) => {
490
+ wrapper = mount (
491
+ < Picker
492
+ selectionRoots = { [ '/Root/Content/HU/Blog/Posts' ] }
493
+ contextPath = "/Root/Content/EN/Blog/Posts"
494
+ repository = { repository ( genericContentItems , helperItems ) as any }
495
+ /> ,
496
+ )
497
+ } )
498
+
499
+ wrapper . update ( )
500
+
501
+ expect (
502
+ wrapper
503
+ . find ( Link )
504
+ . filterWhere ( ( n ) => n . prop ( 'data-test' ) === 'current-content' )
505
+ . exists ( ) ,
506
+ ) . toBeFalsy ( )
507
+ } )
508
+
509
+ it ( 'Should render Selection Roots' , async ( ) => {
510
+ let wrapper : any
481
511
482
512
// helper items should be rendered
483
513
484
- expect ( wrapper . find ( "[data-test='path-helpers']" ) . exists ( ) ) . toBeTruthy ( )
514
+ const helperItems = {
515
+ '/Root/Content/EN/Blog/Posts' : {
516
+ Id : 1 ,
517
+ Name : 'Item1' ,
518
+ DisplayName : 'Display Item1' ,
519
+ Path : '/Root/Content/EN/Blog/Posts' ,
520
+ } ,
521
+ '/Root/Content/HU/Blog/Posts' : {
522
+ Id : 1 ,
523
+ Name : 'Item1' ,
524
+ DisplayName : 'Display Item1' ,
525
+ Path : '/Root/Content/HU/Blog/Posts' ,
526
+ } ,
527
+ }
528
+ const repositoryHandle = ( loadCollectionValue ?: unknown ) => {
529
+ return {
530
+ loadCollection : ( ) => {
531
+ return {
532
+ d : {
533
+ results : loadCollectionValue ,
534
+ } ,
535
+ }
536
+ } ,
537
+ load : ( item ) => {
538
+ return {
539
+ d : helperItems [ item . idOrPath ] ,
540
+ }
541
+ } ,
542
+ }
543
+ }
544
+
545
+ await act ( async ( ) => {
546
+ wrapper = mount (
547
+ < Picker
548
+ selectionRoots = { [ '/Root/Content/HU/Blog/Posts' ] }
549
+ contextPath = "/Root/Content/EN/Blog/Posts"
550
+ repository = { repositoryHandle ( genericContentItems ) as any }
551
+ /> ,
552
+ )
553
+ } )
554
+
555
+ wrapper . update ( )
556
+
557
+ expect (
558
+ wrapper
559
+ . find ( Link )
560
+ . filterWhere ( ( n ) => n . prop ( 'data-test' ) === `path-helper-${ helperItems [ '/Root/Content/HU/Blog/Posts' ] . Path } ` )
561
+ . exists ( ) ,
562
+ ) . toBeTruthy ( )
485
563
486
564
//find helper items length of Link inside data-test path-helpers
487
565
} )
0 commit comments