@@ -271,55 +271,69 @@ describe('put', () => {
271271 const key = 'some-key'
272272 const value = 'some-value'
273273
274- mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 401 ) )
274+ mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 401 , 'myerror' ) )
275275 await expect ( store . put ( key , value ) ) . rejects . toThrow (
276276 expect . objectContaining ( {
277277 sdkDetails : expect . objectContaining ( {
278278 requestId : 'fake-req-id'
279279 } ) ,
280- message : '[AdobeStateLib:ERROR_UNAUTHORIZED] you are not authorized to access State service '
280+ message : '[AdobeStateLib:ERROR_UNAUTHORIZED] myerror '
281281 } ) )
282282 } )
283283
284284 test ( 'coverage: 403 error' , async ( ) => {
285285 const key = 'some-key'
286286 const value = 'some-value'
287287
288- mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 403 ) )
288+ mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 403 , 'myerror' ) )
289289 await expect ( store . put ( key , value ) ) . rejects . toThrow (
290290 expect . objectContaining ( {
291291 sdkDetails : expect . objectContaining ( {
292292 requestId : 'fake-req-id'
293293 } ) ,
294- message : '[AdobeStateLib:ERROR_BAD_CREDENTIALS] cannot access State service, make sure your credentials are valid '
294+ message : '[AdobeStateLib:ERROR_FORBIDDEN] myerror '
295295 } ) )
296296 } )
297297
298298 test ( 'coverage: 413 error' , async ( ) => {
299299 const key = 'some-key'
300300 const value = 'some-value'
301301
302- mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 413 ) )
302+ mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 413 , 'myerror' ) )
303303 await expect ( store . put ( key , value ) ) . rejects . toThrow (
304304 expect . objectContaining ( {
305305 sdkDetails : expect . objectContaining ( {
306306 requestId : 'fake-req-id'
307307 } ) ,
308- message : '[AdobeStateLib:ERROR_PAYLOAD_TOO_LARGE] key, value or request payload is too large State service '
308+ message : '[AdobeStateLib:ERROR_PAYLOAD_TOO_LARGE] myerror '
309309 } ) )
310310 } )
311311
312312 test ( 'coverage: 429 error' , async ( ) => {
313313 const key = 'some-key'
314314 const value = 'some-value'
315315
316- mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 429 ) )
316+ mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 429 , 'myerror' ) )
317317 await expect ( store . put ( key , value ) ) . rejects . toThrow (
318318 expect . objectContaining ( {
319319 sdkDetails : expect . objectContaining ( {
320320 requestId : 'fake-req-id'
321321 } ) ,
322- message : '[AdobeStateLib:ERROR_REQUEST_RATE_TOO_HIGH] Request rate too high. Please retry after sometime.'
322+ message : '[AdobeStateLib:ERROR_REQUEST_RATE_TOO_HIGH] myerror'
323+ } ) )
324+ } )
325+ test ( 'coverage: unknown user error' , async ( ) => {
326+ const key = 'some-key'
327+ const value = 'some-value'
328+ const responseBody = 'error: this is the response body'
329+
330+ mockExponentialBackoff . mockResolvedValue ( wrapInFetchError ( 400 , responseBody ) )
331+ await expect ( store . put ( key , value ) ) . rejects . toThrow (
332+ expect . objectContaining ( {
333+ sdkDetails : expect . objectContaining ( {
334+ requestId : 'fake-req-id'
335+ } ) ,
336+ message : `[AdobeStateLib:ERROR_BAD_REQUEST] ${ responseBody } `
323337 } ) )
324338 } )
325339
@@ -334,7 +348,7 @@ describe('put', () => {
334348 sdkDetails : expect . objectContaining ( {
335349 requestId : 'fake-req-id'
336350 } ) ,
337- message : `[AdobeStateLib:ERROR_INTERNAL] unexpected response from State service with status: 500 body: ${ responseBody } `
351+ message : `[AdobeStateLib:ERROR_INTERNAL] unexpected response from State service with body: ${ responseBody } `
338352 } ) )
339353 } )
340354
0 commit comments