9
9
10
10
import { addErrorMessage , addSuccessMessage } from 'sentry/actionCreators/indicator' ;
11
11
import ConfigStore from 'sentry/stores/configStore' ;
12
- import { browserHistory } from 'sentry/utils/browserHistory ' ;
12
+ import type { InjectedRouter } from 'sentry/types/legacyReactRouter ' ;
13
13
import Relocation from 'sentry/views/relocation/relocation' ;
14
14
15
15
jest . mock ( 'sentry/actionCreators/indicator' ) ;
@@ -38,6 +38,7 @@ const fakeRegions: {[key: string]: FakeRegion} = {
38
38
} ;
39
39
40
40
describe ( 'Relocation' , function ( ) {
41
+ let router : InjectedRouter ;
41
42
let fetchExistingRelocations : jest . Mock ;
42
43
let fetchPublicKeys : jest . Mock ;
43
44
@@ -86,11 +87,12 @@ describe('Relocation', function () {
86
87
step,
87
88
} ;
88
89
89
- const { router , routerProps, organization} = initializeOrg ( {
90
+ const { routerProps, organization, ... rest } = initializeOrg ( {
90
91
router : {
91
92
params : routeParams ,
92
93
} ,
93
94
} ) ;
95
+ router = rest . router ;
94
96
95
97
return render ( < Relocation { ...routerProps } /> , {
96
98
router,
@@ -144,7 +146,7 @@ describe('Relocation', function () {
144
146
await waitFor ( ( ) => expect ( fetchExistingRelocations ) . toHaveBeenCalledTimes ( 2 ) ) ;
145
147
await waitFor ( ( ) => expect ( fetchPublicKeys ) . toHaveBeenCalledTimes ( 2 ) ) ;
146
148
147
- expect ( browserHistory . push ) . toHaveBeenCalledWith ( '/relocation/in-progress/' ) ;
149
+ expect ( router . push ) . toHaveBeenCalledWith ( '/relocation/in-progress/' ) ;
148
150
} ) ;
149
151
150
152
it ( 'should prevent user from going to the next step if no org slugs or region are entered' , async function ( ) {
@@ -365,7 +367,7 @@ describe('Relocation', function () {
365
367
await waitFor ( ( ) => expect ( fetchExistingRelocations ) . toHaveBeenCalledTimes ( 2 ) ) ;
366
368
await waitFor ( ( ) => expect ( fetchPublicKeys ) . toHaveBeenCalledTimes ( 2 ) ) ;
367
369
368
- expect ( browserHistory . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
370
+ expect ( router . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
369
371
} ) ;
370
372
} ) ;
371
373
@@ -394,7 +396,7 @@ describe('Relocation', function () {
394
396
await waitFor ( ( ) => expect ( fetchExistingRelocations ) . toHaveBeenCalledTimes ( 2 ) ) ;
395
397
await waitFor ( ( ) => expect ( fetchPublicKeys ) . toHaveBeenCalledTimes ( 2 ) ) ;
396
398
397
- expect ( browserHistory . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
399
+ expect ( router . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
398
400
} ) ;
399
401
} ) ;
400
402
@@ -591,7 +593,7 @@ describe('Relocation', function () {
591
593
await waitFor ( ( ) => expect ( fetchExistingRelocations ) . toHaveBeenCalledTimes ( 2 ) ) ;
592
594
await waitFor ( ( ) => expect ( fetchPublicKeys ) . toHaveBeenCalledTimes ( 2 ) ) ;
593
595
594
- expect ( browserHistory . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
596
+ expect ( router . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
595
597
} ) ;
596
598
} ) ;
597
599
@@ -625,7 +627,7 @@ describe('Relocation', function () {
625
627
await waitFor ( ( ) => expect ( fetchExistingRelocations ) . toHaveBeenCalledTimes ( 2 ) ) ;
626
628
await waitFor ( ( ) => expect ( fetchPublicKeys ) . toHaveBeenCalledTimes ( 2 ) ) ;
627
629
628
- expect ( browserHistory . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
630
+ expect ( router . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
629
631
} ) ;
630
632
631
633
it ( 'redirects to `get-started` page if there is no active relocation' , async function ( ) {
@@ -650,7 +652,7 @@ describe('Relocation', function () {
650
652
await waitFor ( ( ) => expect ( fetchExistingRelocations ) . toHaveBeenCalledTimes ( 2 ) ) ;
651
653
await waitFor ( ( ) => expect ( fetchPublicKeys ) . toHaveBeenCalledTimes ( 2 ) ) ;
652
654
653
- expect ( browserHistory . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
655
+ expect ( router . push ) . toHaveBeenCalledWith ( '/relocation/get-started/' ) ;
654
656
} ) ;
655
657
} ) ;
656
658
} ) ;
0 commit comments