File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
setTag ,
11
11
setTags ,
12
12
setUser ,
13
+ startTransaction ,
13
14
withScope ,
14
15
} from '../src/exports' ;
15
16
@@ -184,6 +185,35 @@ describe('Top Level API', () => {
184
185
} ) ;
185
186
} ) ;
186
187
188
+ describe ( 'startTransaction' , ( ) => {
189
+ beforeEach ( ( ) => {
190
+ global . __SENTRY__ = {
191
+ hub : undefined ,
192
+ extensions : {
193
+ startTransaction : ( context : any ) => ( {
194
+ name : context . name ,
195
+ // Spread rather than assign in case it's undefined
196
+ metadata : { ...context . metadata } ,
197
+ } ) ,
198
+ } ,
199
+ } ;
200
+ } ) ;
201
+
202
+ it ( "sets source to `'custom'` if no source provided" , ( ) => {
203
+ const transaction = startTransaction ( { name : 'dogpark' } ) ;
204
+
205
+ expect ( transaction . name ) . toEqual ( 'dogpark' ) ;
206
+ expect ( transaction . metadata . source ) . toEqual ( 'custom' ) ;
207
+ } ) ;
208
+
209
+ it ( 'uses given `source` value' , ( ) => {
210
+ const transaction = startTransaction ( { name : 'dogpark' , metadata : { source : 'route' } } ) ;
211
+
212
+ expect ( transaction . name ) . toEqual ( 'dogpark' ) ;
213
+ expect ( transaction . metadata . source ) . toEqual ( 'route' ) ;
214
+ } ) ;
215
+ } ) ;
216
+
187
217
test ( 'Clear Scope' , ( ) => {
188
218
const client : any = new TestClient ( { } ) ;
189
219
getCurrentHub ( ) . withScope ( ( ) => {
You can’t perform that action at this time.
0 commit comments