@@ -9,37 +9,26 @@ declare module 'react-router-3' {
9
9
type History = { replace : Function ; push : Function } ;
10
10
export function createMemoryHistory ( ) : History ;
11
11
export const Router : React . ComponentType < { history : History } > ;
12
- export const Route : React . ComponentType < { path : string ; component : React . ComponentType < any > } > ;
12
+ export const Route : React . ComponentType < { path : string ; component ? : React . ComponentType < any > } > ;
13
13
export const IndexRoute : React . ComponentType < { component : React . ComponentType < any > } > ;
14
14
export const match : Match ;
15
15
export const createRoutes : ( routes : any ) => RouteType [ ] ;
16
16
}
17
17
18
- const App : React . FC = ( { children } ) => < div > { children } </ div > ;
19
-
20
- function Home ( ) : JSX . Element {
21
- return < div > Home</ div > ;
22
- }
23
-
24
- function About ( ) : JSX . Element {
25
- return < div > About</ div > ;
26
- }
27
-
28
- function Features ( ) : JSX . Element {
29
- return < div > Features</ div > ;
30
- }
31
-
32
- function Users ( { params } : { params : Record < string , string > } ) : JSX . Element {
33
- return < div > { params . userid } </ div > ;
34
- }
35
-
36
18
describe ( 'React Router V3' , ( ) => {
37
19
const routes = (
38
- < Route path = "/" component = { App } >
39
- < IndexRoute component = { Home } />
40
- < Route path = "about" component = { About } />
41
- < Route path = "features" component = { Features } />
42
- < Route path = "users/:userid" component = { Users } />
20
+ < Route path = "/" component = { ( { children } : { children : JSX . Element } ) => < div > { children } </ div > } >
21
+ < IndexRoute component = { ( ) => < div > Home</ div > } />
22
+ < Route path = "about" component = { ( ) => < div > About</ div > } />
23
+ < Route path = "features" component = { ( ) => < div > Features</ div > } />
24
+ < Route
25
+ path = "users/:userid"
26
+ component = { ( { params } : { params : Record < string , string > } ) => < div > { params . userid } </ div > }
27
+ />
28
+ < Route path = "organizations/" >
29
+ < Route path = ":orgid" component = { ( ) => < div > OrgId</ div > } />
30
+ < Route path = ":orgid/v1/:teamid" component = { ( ) => < div > Team</ div > } />
31
+ </ Route >
43
32
</ Route >
44
33
) ;
45
34
const history = createMemoryHistory ( ) ;
@@ -129,4 +118,30 @@ describe('React Router V3', () => {
129
118
tags : { from : '/' , 'routing.instrumentation' : 'react-router-v3' } ,
130
119
} ) ;
131
120
} ) ;
121
+
122
+ it ( 'normalizes nested transaction names' , ( ) => {
123
+ const mockStartTransaction = jest . fn ( ) ;
124
+ instrumentation ( mockStartTransaction ) ;
125
+ const { container } = render ( < Router history = { history } > { routes } </ Router > ) ;
126
+
127
+ history . push ( '/organizations/1234/v1/758' ) ;
128
+ expect ( container . innerHTML ) . toContain ( 'Team' ) ;
129
+
130
+ expect ( mockStartTransaction ) . toHaveBeenCalledTimes ( 2 ) ;
131
+ expect ( mockStartTransaction ) . toHaveBeenLastCalledWith ( {
132
+ name : '/organizations/:orgid/v1/:teamid' ,
133
+ op : 'navigation' ,
134
+ tags : { from : '/' , 'routing.instrumentation' : 'react-router-v3' } ,
135
+ } ) ;
136
+
137
+ history . push ( '/organizations/543' ) ;
138
+ expect ( container . innerHTML ) . toContain ( 'OrgId' ) ;
139
+
140
+ expect ( mockStartTransaction ) . toHaveBeenCalledTimes ( 3 ) ;
141
+ expect ( mockStartTransaction ) . toHaveBeenLastCalledWith ( {
142
+ name : '/organizations/:orgid' ,
143
+ op : 'navigation' ,
144
+ tags : { from : '/organizations/:orgid/v1/:teamid' , 'routing.instrumentation' : 'react-router-v3' } ,
145
+ } ) ;
146
+ } ) ;
132
147
} ) ;
0 commit comments