1+ import type { UIMatch } from 'react-router-dom' ;
12import { LocationFixture } from 'sentry-fixture/locationFixture' ;
23import { OrganizationFixture } from 'sentry-fixture/organization' ;
3- import { RouterPropsFixture } from 'sentry-fixture/routerPropsFixture' ;
44
55import { ProjectFixture } from 'getsentry-test/fixtures/project' ;
66import { SubscriptionFixture } from 'getsentry-test/fixtures/subscription' ;
@@ -18,6 +18,13 @@ const HALF_ADVANCE_PERIOD = DELAY_TIME_MS * 0.6;
1818
1919jest . mock ( 'getsentry/utils/rawTrackAnalyticsEvent' ) ;
2020
21+ function makeMatch ( path : string ) : UIMatch {
22+ return { id : path , pathname : path , params : { } , data : undefined , handle : { path} } ;
23+ }
24+
25+ const SETTINGS_MATCHES = [ makeMatch ( '/settings/:orgId/projects/:projectId/' ) ] ;
26+ const RELEASES_MATCHES = [ makeMatch ( '/organizations/:orgId/releases/:release/' ) ] ;
27+
2128describe ( 'useRouteActivatedHook' , ( ) => {
2229 const organization = OrganizationFixture ( ) ;
2330 const project = ProjectFixture ( { organization} ) ;
@@ -27,18 +34,13 @@ describe('useRouteActivatedHook', () => {
2734 function genProps ( extraRouteParams = { } ) : any {
2835 const props = {
2936 organization,
30- ...RouterPropsFixture ( {
31- location : LocationFixture ( {
32- pathname : `/settings/${ organization . slug } /${ project . slug } /` ,
33- } ) ,
34- params : { orgId : organization . slug } ,
35- routes : [
36- { path : '/' } ,
37- { path : '/settings/' } ,
38- { path : ':orgId/' } ,
39- { path : 'projects/:projectId/' } ,
40- ] ,
37+ location : LocationFixture ( {
38+ pathname : `/settings/${ organization . slug } /${ project . slug } /` ,
4139 } ) ,
40+ params : { orgId : organization . slug } ,
41+ routes : [ ] ,
42+ router : { } as any ,
43+ matches : SETTINGS_MATCHES ,
4244 ...extraRouteParams ,
4345 } ;
4446 return props ;
@@ -173,14 +175,7 @@ describe('useRouteActivatedHook', () => {
173175 location : LocationFixture ( {
174176 pathname : `/organizations/${ organization . slug } /releases/some-release/` ,
175177 } ) ,
176- routes : [
177- { path : '/' } ,
178- { path : '/organizations/:orgId/releases/' } ,
179- { path : ':release/' } ,
180- ] ,
181- ...LocationFixture ( {
182- pathname : `/organizations/${ organization . slug } /releases/some-release/` ,
183- } ) ,
178+ matches : RELEASES_MATCHES ,
184179 } ) ;
185180 const loadTime = Date . now ( ) ;
186181 act ( ( ) => rerender ( newProps ) ) ;
@@ -225,6 +220,7 @@ describe('useRouteActivatedHook', () => {
225220 it ( 'route changes triggers early analytics event' , ( ) => {
226221 jest . useFakeTimers ( ) ;
227222 let loadTime = Date . now ( ) ;
223+
228224 const { result, rerender} = renderHook ( useRouteActivatedHook , {
229225 initialProps : props ,
230226 } ) ;
@@ -235,14 +231,7 @@ describe('useRouteActivatedHook', () => {
235231 location : LocationFixture ( {
236232 pathname : `/organizations/${ organization . slug } /releases/some-release/` ,
237233 } ) ,
238- routes : [
239- { path : '/' } ,
240- { path : '/organizations/:orgId/releases/' } ,
241- { path : ':release/' } ,
242- ] ,
243- ...LocationFixture ( {
244- pathname : `/organizations/${ organization . slug } /releases/some-release/` ,
245- } ) ,
234+ matches : RELEASES_MATCHES ,
246235 } ) ;
247236 expect ( rawTrackAnalyticsEvent ) . toHaveBeenCalledTimes ( 0 ) ;
248237
0 commit comments