@@ -14,8 +14,8 @@ import createFetchDeliveryFactory from '../lib/delivery'
1414const SENT_AT_FORMAT = / ^ \d { 4 } - \d { 2 } - \d { 2 } T \d { 2 } : \d { 2 } : \d { 2 } \. \d { 3 } Z $ /
1515
1616describe ( 'Browser Delivery' , ( ) => {
17- it ( 'delivers a span' , ( ) => {
18- const fetch = jest . fn ( ( ) => Promise . resolve ( { } as unknown as Response ) )
17+ it ( 'delivers a span' , async ( ) => {
18+ const fetch = jest . fn ( ( ) => Promise . resolve ( { status : 200 , headers : new Headers ( ) } as unknown as Response ) )
1919 const backgroundingListener = new ControllableBackgroundingListener ( )
2020 const clock = new IncrementingClock ( '2023-01-02T00:00:00.000Z' )
2121
@@ -47,7 +47,7 @@ describe('Browser Delivery', () => {
4747
4848 const deliveryFactory = createFetchDeliveryFactory ( fetch , clock , backgroundingListener )
4949 const delivery = deliveryFactory ( '/test' )
50- delivery . send ( deliveryPayload )
50+ const response = await delivery . send ( deliveryPayload )
5151
5252 expect ( fetch ) . toHaveBeenCalledWith ( '/test' , {
5353 method : 'POST' ,
@@ -60,10 +60,15 @@ describe('Browser Delivery', () => {
6060 'Bugsnag-Sent-At' : new Date ( clock . timeOrigin + 1 ) . toISOString ( )
6161 }
6262 } )
63+
64+ expect ( response ) . toStrictEqual ( {
65+ state : 'success' ,
66+ samplingProbability : undefined
67+ } )
6368 } )
6469
65- it ( 'delivers a span with keepalive = true when the app is backgrounded' , ( ) => {
66- const fetch = jest . fn ( ( ) => Promise . resolve ( { } as unknown as Response ) )
70+ it ( 'delivers a span with keepalive = true when the app is backgrounded' , async ( ) => {
71+ const fetch = jest . fn ( ( ) => Promise . resolve ( { status : 200 , headers : new Headers ( ) } as unknown as Response ) )
6772 const backgroundingListener = new ControllableBackgroundingListener ( )
6873
6974 const deliveryPayload : TracePayload = {
@@ -97,7 +102,7 @@ describe('Browser Delivery', () => {
97102
98103 backgroundingListener . sendToBackground ( )
99104
100- delivery . send ( deliveryPayload )
105+ const response = await delivery . send ( deliveryPayload )
101106
102107 expect ( fetch ) . toHaveBeenCalledWith ( '/test' , {
103108 method : 'POST' ,
@@ -110,10 +115,15 @@ describe('Browser Delivery', () => {
110115 'Bugsnag-Sent-At' : expect . stringMatching ( SENT_AT_FORMAT )
111116 }
112117 } )
118+
119+ expect ( response ) . toStrictEqual ( {
120+ state : 'success' ,
121+ samplingProbability : undefined
122+ } )
113123 } )
114124
115- it ( 'delivers a span with keepalive = false when the app is returned to the foreground' , ( ) => {
116- const fetch = jest . fn ( ( ) => Promise . resolve ( { } as unknown as Response ) )
125+ it ( 'delivers a span with keepalive = false when the app is returned to the foreground' , async ( ) => {
126+ const fetch = jest . fn ( ( ) => Promise . resolve ( { status : 200 , headers : new Headers ( ) } as unknown as Response ) )
117127 const backgroundingListener = new ControllableBackgroundingListener ( )
118128
119129 const deliveryPayload : TracePayload = {
@@ -148,7 +158,7 @@ describe('Browser Delivery', () => {
148158 backgroundingListener . sendToBackground ( )
149159 backgroundingListener . sendToForeground ( )
150160
151- delivery . send ( deliveryPayload )
161+ const response = await delivery . send ( deliveryPayload )
152162
153163 expect ( fetch ) . toHaveBeenCalledWith ( '/test' , {
154164 method : 'POST' ,
@@ -161,6 +171,11 @@ describe('Browser Delivery', () => {
161171 'Bugsnag-Sent-At' : expect . stringMatching ( SENT_AT_FORMAT )
162172 }
163173 } )
174+
175+ expect ( response ) . toStrictEqual ( {
176+ state : 'success' ,
177+ samplingProbability : undefined
178+ } )
164179 } )
165180
166181 it . each ( [
0 commit comments