@@ -442,6 +442,7 @@ describe('DataTableContainer - Row Click', () => {
442
442
let component : RenderResult ;
443
443
let nexus : ReturnType < typeof createNexusClient > ;
444
444
let nexusSpy : jest . SpyInstance ;
445
+ let historySpy : jest . SpyInstance ;
445
446
446
447
beforeAll ( ( ) => {
447
448
server = setupServer (
@@ -495,6 +496,7 @@ describe('DataTableContainer - Row Click', () => {
495
496
? Promise . resolve ( [ getMockResource ( 'doesnt-matter' , { } , 'agents' ) ] )
496
497
: Promise . resolve ( getMockResource ( 'doesnt-matter' , { } , 'agents' ) )
497
498
) ;
499
+ historySpy = vitest . spyOn ( history , 'push' ) ;
498
500
} ) ;
499
501
500
502
// reset any request handlers that are declared as a part of our tests
@@ -504,6 +506,7 @@ describe('DataTableContainer - Row Click', () => {
504
506
queryClient . clear ( ) ;
505
507
localStorage . clear ( ) ;
506
508
nexusSpy . mockClear ( ) ;
509
+ historySpy . mockClear ( ) ;
507
510
} ) ;
508
511
509
512
afterAll ( ( ) => {
@@ -538,6 +541,8 @@ describe('DataTableContainer - Row Click', () => {
538
541
path : `${ selfWithRevision } &format=expanded` ,
539
542
headers : { Accept : 'application/json' } ,
540
543
} ) ;
544
+ const navigateTo = historySpy . mock . calls [ 0 ] [ 0 ] ;
545
+ expect ( navigateTo ) . toContain ( 'rev=30' ) ;
541
546
} ) ;
542
547
543
548
it ( 'requests correct resource from delta when user clicks on row with tag in self' , async ( ) => {
@@ -555,11 +560,13 @@ describe('DataTableContainer - Row Click', () => {
555
560
path : `${ selfWithTag } &format=expanded` ,
556
561
headers : { Accept : 'application/json' } ,
557
562
} ) ;
563
+ const navigateTo = historySpy . mock . calls [ 0 ] [ 0 ] ;
564
+ expect ( navigateTo ) . toContain ( 'tag=30' ) ;
558
565
} ) ;
559
566
560
567
it ( 'requests correct resource from delta when user clicks on row with tag and revision in self' , async ( ) => {
561
568
const selfWithTagAndRev =
562
- 'https://localhost:3000/resources/bbp/agents/_/persons%2Fc3358e61-7650-4954-99b7-f7572cbf5d5g?tag=30&rev=2- ' ;
569
+ 'https://localhost:3000/resources/bbp/agents/_/persons%2Fc3358e61-7650-4954-99b7-f7572cbf5d5g?tag=30&rev=20 ' ;
563
570
564
571
const resources = [ getMockStudioResource ( 'Malory' , `${ selfWithTagAndRev } ` ) ] ;
565
572
@@ -572,6 +579,8 @@ describe('DataTableContainer - Row Click', () => {
572
579
path : `${ selfWithTagAndRev } &format=expanded` ,
573
580
headers : { Accept : 'application/json' } ,
574
581
} ) ;
582
+ const navigateTo = historySpy . mock . calls [ 0 ] [ 0 ] ;
583
+ expect ( navigateTo ) . toContain ( 'rev=20' ) ;
575
584
} ) ;
576
585
577
586
it ( 'requests correct resource from delta when user clicks on row with no tag or revision in self' , async ( ) => {
@@ -591,6 +600,9 @@ describe('DataTableContainer - Row Click', () => {
591
600
path : `${ selfWithoutTagOrRev } ?format=expanded` ,
592
601
headers : { Accept : 'application/json' } ,
593
602
} ) ;
603
+ const navigateTo = historySpy . mock . calls [ 0 ] [ 0 ] ;
604
+ expect ( navigateTo ) . not . toContain ( 'rev' ) ;
605
+ expect ( navigateTo ) . not . toContain ( 'tag' ) ;
594
606
} ) ;
595
607
} ) ;
596
608
0 commit comments