File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
1010  setTag , 
1111  setTags , 
1212  setUser , 
13+   startTransaction , 
1314  withScope , 
1415}  from  '../src/exports' ; 
1516
@@ -184,6 +185,35 @@ describe('Top Level API', () => {
184185    } ) ; 
185186  } ) ; 
186187
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+ 
187217  test ( 'Clear Scope' ,  ( )  =>  { 
188218    const  client : any  =  new  TestClient ( { } ) ; 
189219    getCurrentHub ( ) . withScope ( ( )  =>  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments