@@ -338,13 +338,34 @@ describe('_addResourceSpans', () => {
338
338
} ) ,
339
339
) ;
340
340
} ) ;
341
- } ) ;
342
341
343
- // resource delivery types: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType
344
- // i.e. better but not yet widely supported way to check for browser cache hit
345
- it . each ( [ '' , 'cache' , 'navigational-prefetch' ] ) (
346
- 'attaches delivery type to resource spans if available' ,
347
- deliveryType => {
342
+ // resource delivery types: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming/deliveryType
343
+ // i.e. better but not yet widely supported way to check for browser cache hit
344
+ it . each ( [ 'cache' , 'navigational-prefetch' ] ) (
345
+ 'attaches delivery type ("%s") to resource spans if available' ,
346
+ deliveryType => {
347
+ const spans : Span [ ] = [ ] ;
348
+
349
+ getClient ( ) ?. on ( 'spanEnd' , span => {
350
+ spans . push ( span ) ;
351
+ } ) ;
352
+
353
+ const entry : ResourceEntry = {
354
+ initiatorType : 'css' ,
355
+ transferSize : 0 ,
356
+ encodedBodySize : 0 ,
357
+ decodedBodySize : 0 ,
358
+ deliveryType,
359
+ } ;
360
+
361
+ _addResourceSpans ( span , entry , resourceEntryName , 100 , 23 , 345 ) ;
362
+
363
+ expect ( spans ) . toHaveLength ( 1 ) ;
364
+ expect ( spanToJSON ( spans [ 0 ] ! ) . data ) . toMatchObject ( { 'http.response_delivery_type' : deliveryType } ) ;
365
+ } ,
366
+ ) ;
367
+
368
+ it ( 'attaches "default" as delivery if the empty string ("") default value is set' , ( ) => {
348
369
const spans : Span [ ] = [ ] ;
349
370
350
371
getClient ( ) ?. on ( 'spanEnd' , span => {
@@ -356,15 +377,15 @@ it.each(['', 'cache', 'navigational-prefetch'])(
356
377
transferSize : 0 ,
357
378
encodedBodySize : 0 ,
358
379
decodedBodySize : 0 ,
359
- deliveryType,
380
+ deliveryType : '' ,
360
381
} ;
361
382
362
383
_addResourceSpans ( span , entry , resourceEntryName , 100 , 23 , 345 ) ;
363
384
364
385
expect ( spans ) . toHaveLength ( 1 ) ;
365
- expect ( spanToJSON ( spans [ 0 ] ! ) ) . toEqual ( expect . objectContaining ( { 'http.response_delivery_type' : deliveryType } ) ) ;
366
- } ,
367
- ) ;
386
+ expect ( spanToJSON ( spans [ 0 ] ! ) . data ) . toMatchObject ( { 'http.response_delivery_type' : 'default' } ) ;
387
+ } ) ;
388
+ } ) ;
368
389
369
390
const setGlobalLocation = ( location : Location ) => {
370
391
// @ts -expect-error need to delete this in order to set to new value
0 commit comments