Skip to content

Commit 00e3d41

Browse files
test(js): Remove browserHistory from relocation.spec (#82595)
1 parent d5e6ef7 commit 00e3d41

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

static/app/views/relocation/relocation.spec.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
1111
import ConfigStore from 'sentry/stores/configStore';
12-
import {browserHistory} from 'sentry/utils/browserHistory';
12+
import type {InjectedRouter} from 'sentry/types/legacyReactRouter';
1313
import Relocation from 'sentry/views/relocation/relocation';
1414

1515
jest.mock('sentry/actionCreators/indicator');
@@ -38,6 +38,7 @@ const fakeRegions: {[key: string]: FakeRegion} = {
3838
};
3939

4040
describe('Relocation', function () {
41+
let router: InjectedRouter;
4142
let fetchExistingRelocations: jest.Mock;
4243
let fetchPublicKeys: jest.Mock;
4344

@@ -86,11 +87,12 @@ describe('Relocation', function () {
8687
step,
8788
};
8889

89-
const {router, routerProps, organization} = initializeOrg({
90+
const {routerProps, organization, ...rest} = initializeOrg({
9091
router: {
9192
params: routeParams,
9293
},
9394
});
95+
router = rest.router;
9496

9597
return render(<Relocation {...routerProps} />, {
9698
router,
@@ -144,7 +146,7 @@ describe('Relocation', function () {
144146
await waitFor(() => expect(fetchExistingRelocations).toHaveBeenCalledTimes(2));
145147
await waitFor(() => expect(fetchPublicKeys).toHaveBeenCalledTimes(2));
146148

147-
expect(browserHistory.push).toHaveBeenCalledWith('/relocation/in-progress/');
149+
expect(router.push).toHaveBeenCalledWith('/relocation/in-progress/');
148150
});
149151

150152
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 () {
365367
await waitFor(() => expect(fetchExistingRelocations).toHaveBeenCalledTimes(2));
366368
await waitFor(() => expect(fetchPublicKeys).toHaveBeenCalledTimes(2));
367369

368-
expect(browserHistory.push).toHaveBeenCalledWith('/relocation/get-started/');
370+
expect(router.push).toHaveBeenCalledWith('/relocation/get-started/');
369371
});
370372
});
371373

@@ -394,7 +396,7 @@ describe('Relocation', function () {
394396
await waitFor(() => expect(fetchExistingRelocations).toHaveBeenCalledTimes(2));
395397
await waitFor(() => expect(fetchPublicKeys).toHaveBeenCalledTimes(2));
396398

397-
expect(browserHistory.push).toHaveBeenCalledWith('/relocation/get-started/');
399+
expect(router.push).toHaveBeenCalledWith('/relocation/get-started/');
398400
});
399401
});
400402

@@ -591,7 +593,7 @@ describe('Relocation', function () {
591593
await waitFor(() => expect(fetchExistingRelocations).toHaveBeenCalledTimes(2));
592594
await waitFor(() => expect(fetchPublicKeys).toHaveBeenCalledTimes(2));
593595

594-
expect(browserHistory.push).toHaveBeenCalledWith('/relocation/get-started/');
596+
expect(router.push).toHaveBeenCalledWith('/relocation/get-started/');
595597
});
596598
});
597599

@@ -625,7 +627,7 @@ describe('Relocation', function () {
625627
await waitFor(() => expect(fetchExistingRelocations).toHaveBeenCalledTimes(2));
626628
await waitFor(() => expect(fetchPublicKeys).toHaveBeenCalledTimes(2));
627629

628-
expect(browserHistory.push).toHaveBeenCalledWith('/relocation/get-started/');
630+
expect(router.push).toHaveBeenCalledWith('/relocation/get-started/');
629631
});
630632

631633
it('redirects to `get-started` page if there is no active relocation', async function () {
@@ -650,7 +652,7 @@ describe('Relocation', function () {
650652
await waitFor(() => expect(fetchExistingRelocations).toHaveBeenCalledTimes(2));
651653
await waitFor(() => expect(fetchPublicKeys).toHaveBeenCalledTimes(2));
652654

653-
expect(browserHistory.push).toHaveBeenCalledWith('/relocation/get-started/');
655+
expect(router.push).toHaveBeenCalledWith('/relocation/get-started/');
654656
});
655657
});
656658
});

0 commit comments

Comments
 (0)