@@ -290,51 +290,16 @@ describe('Hub', () => {
290
290
expect ( span . _spanId ) . toBeTruthy ( ) ;
291
291
} ) ;
292
292
293
- test ( 'bindOnScope ' , ( ) => {
293
+ test ( 'inherits from parent span ' , ( ) => {
294
294
const myScope = new Scope ( ) ;
295
295
const hub = new Hub ( clientFn , myScope ) ;
296
- const span = hub . startSpan ( { } , true ) as any ;
297
- expect ( ( myScope as any ) . _span ) . toBe ( span ) ;
298
- } ) ;
299
- } ) ;
300
-
301
- describe ( 'finish' , ( ) => {
302
- test ( 'simple' , ( ) => {
303
- const hub = new Hub ( clientFn ) ;
304
- const span = hub . startSpan ( ) as any ;
305
- expect ( span . timestamp ) . toBeUndefined ( ) ;
306
- expect ( hub . finishSpan ( span ) ) . toBeUndefined ( ) ;
307
- expect ( span . timestamp ) . toBeGreaterThan ( 1 ) ;
308
- } ) ;
309
-
310
- test ( 'finish a scope span without transaction' , ( ) => {
311
- const myScope = new Scope ( ) ;
312
- const hub = new Hub ( clientFn , myScope ) ;
313
- const spy = jest . spyOn ( hub as any , 'captureEvent' ) ;
314
- const span = hub . startSpan ( { } , true ) as any ;
315
- expect ( hub . finishSpan ( span ) ) . toBeUndefined ( ) ;
316
- expect ( spy ) . not . toHaveBeenCalled ( ) ;
317
- } ) ;
318
-
319
- test ( 'finish a scope span with transaction' , ( ) => {
320
- const myScope = new Scope ( ) ;
321
- const hub = new Hub ( clientFn , myScope ) ;
322
- const spy = jest . spyOn ( hub as any , 'captureEvent' ) ;
323
- const span = hub . startSpan ( { transaction : 'test' } , true ) as any ;
324
- expect ( hub . finishSpan ( span ) ) . toBeDefined ( ) ;
325
- expect ( spy ) . toHaveBeenCalled ( ) ;
326
- expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toBeUndefined ( ) ;
327
- } ) ;
328
-
329
- test ( 'finish a scope span with transaction + child span' , ( ) => {
330
- const myScope = new Scope ( ) ;
331
- const hub = new Hub ( clientFn , myScope ) ;
332
- const spy = jest . spyOn ( hub as any , 'captureEvent' ) ;
333
- const span = hub . startSpan ( { transaction : 'test' } , true ) as any ;
334
- hub . finishSpan ( hub . startSpan ( ) ) ;
335
- expect ( hub . finishSpan ( span ) ) . toBeDefined ( ) ;
336
- expect ( spy ) . toHaveBeenCalled ( ) ;
337
- expect ( spy . mock . calls [ 0 ] [ 0 ] . spans ) . toHaveLength ( 1 ) ;
296
+ const parentSpan = hub . startSpan ( { } ) as any ;
297
+ expect ( parentSpan . _parentId ) . toBeFalsy ( ) ;
298
+ hub . configureScope ( scope => {
299
+ scope . setSpan ( parentSpan ) ;
300
+ } ) ;
301
+ const span = hub . startSpan ( { } ) as any ;
302
+ expect ( span . _parentSpanId ) . toBeTruthy ( ) ;
338
303
} ) ;
339
304
} ) ;
340
305
} ) ;
0 commit comments